Docker Community Forums

Share and learn in the Docker community.

How would I go about modifying my Dockerfile/docker-compose to support dev and production environments?

Hi. I’ve been using Docker with Docker Compose for production deployments. Currently the only way I’ve found to get around my current problem is to use a second docker-compose.yml file but there’s got to be a better way. So here goes. For development purposes my application uses a shared folder and loads it into the container with the Ruby On Rails Application code.

My docker compose and docker file are at https://gist.github.com/nsuchy/19a75202c070c181b3f1ed42c445f19c

In development I run docker-compose run app --with-service-ports bash from there I have my dev environment and can run rails server -e production|development -b '0.0.0.0' and have an easy way to test my changes as it’s mounted to the shared folder.

In production however I would want to copy those files from the shared folder into the container for easy deployments from GitLab Container Registry.

How would I go about making a different image for production (e.g. no shared folder) without temporarily replacing my docker-compose file or my docker file?

The current dev method is really nice but changes are needed to avoid having to clone the code from GitLab. I also want to avoid needing a temporary docker/docker-compose file.