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:
@@ -33,8 +33,10 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- .:/var/www/consul
|
- .:/var/www/consul
|
||||||
- bundle:/usr/local/bundle
|
- bundle:/usr/local/bundle
|
||||||
|
- node_modules:/var/www/consul/node_modules
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_PASSWORD=$POSTGRES_PASSWORD
|
- POSTGRES_PASSWORD=$POSTGRES_PASSWORD
|
||||||
volumes:
|
volumes:
|
||||||
db_data: {}
|
db_data: {}
|
||||||
bundle: {}
|
bundle: {}
|
||||||
|
node_modules: {}
|
||||||
|
|||||||
Reference in New Issue
Block a user