rpg-boilerplate icon indicating copy to clipboard operation
rpg-boilerplate copied to clipboard

Why do we need to mount volumes to the frontend and api?

Open Antibioticvz opened this issue 7 years ago • 3 comments

I'm working now to make it run on aws ecs and I have some troubles to mount volumes to containers Why do we need to copy folders(Dockerfile) to the Image build COPY . /opt/app COPY . /opt/frontend and also mount volumes from yml volumes: - ./frontend/.:/opt/frontend - /opt/frontend/node_modules volumes: - ./api/.:/opt/app - /opt/app/node_modules also we copy api and all files and next api/node_modules, is it right? For me it's looks redundant.

Antibioticvz avatar Feb 18 '18 20:02 Antibioticvz

We copy the folders because that is where the code is. For example, /api/Dockerfile copies in the contents of /api/.* and then that is what is run via node.

The docker-compose.yml is only used locally. The Dockerfile builds an image, so the files need to be inside the image. The docker-compose mounts the volumes so that our watch-scripts will detect changes and reload.

We are not copying in node_modules, though. We exclude node modules in the docker-compose.yml because the docker/run.sh file uses a yarn cache inside the container to make it so that modules are only downloaded when package.json changes

We also use the Dockerfile to build the image on the CI server, and that is why there is also a yarn command in there to install the modules

chadfurman avatar Feb 19 '18 00:02 chadfurman

That's make sense to me thank you. So the db/Dockerfile need this COPY /postgres-data /var/lib/postgresql/data/pgdata I think

Antibioticvz avatar Feb 19 '18 02:02 Antibioticvz

Hmmmmm maybe... /postgres-data has generally just worked for me. However, I do not rely on the postgres image but rather I use RDS and deploy my migrations as the root user

chadfurman avatar Feb 20 '18 15:02 chadfurman