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.
This commit is contained in:
Javi Martín
2024-09-16 00:38:41 +02:00
parent 18dfa643f0
commit 40d82037d1

View File

@@ -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: {}