From 40d82037d1595f5a32525ec54e9e43cf40b395a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 16 Sep 2024 00:38:41 +0200 Subject: [PATCH] Don't overwrite node_modules with Docker Compose When creating the Dockerfile, we run `npm install`, which creates a `node_modules` folder inside the working directory. However, when using docker-compose, we overwrite the contents of that working directory (/var/www/consul) with the contents of the host machine's working directory. This means that, unless the `npm install` command is run on the host machine to create a `node_modules` folder on the host machine (which would pretty much defeat the point of using Docker), the container won't have a `node_modules` folder and the application won't run. So we're defining a volume in docker-compose.yml to make sure we keep the container's `node_modules` folder. --- docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 89b377968..21132bf8e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,8 +33,10 @@ services: volumes: - .:/var/www/consul - bundle:/usr/local/bundle + - node_modules:/var/www/consul/node_modules environment: - POSTGRES_PASSWORD=$POSTGRES_PASSWORD volumes: db_data: {} bundle: {} + node_modules: {}