My Configuration
My docker-compose.yml looks like this with some config for backend etc..., but I need some changes for db
service.
version: '3.6'
services:
db:
container_name: db-${STAGE:-dev}
image: postgres:14.0-alpine
volumes:
- postgres_data:/var/lib/postgresql/data/
ports:
- "5432:5432"
env_file:
- .env.${STAGE:-dev}
I don't want to have multiple docker-compose.yml files, so...
What do I want?
I want to run this docker-compose.yml twice, the first time with STAGE=prod and the second time with STAGE=dev. I need to use different .env files (.env.dev, .env.prod), because of once the db
service is built, the image name is postgres:14.0-alpine
and it also builds with only one of the .env.${STAGE} files, so it will only work with development
or production
, due to different passwords etc....
I want to build 2 different images for postgres db (e.g. db-dev and db-prod) that will use .env.dev for db-dev and .env.prod for db-prod.
The reason I want to do this is that I would like to deploy both a development and a production server on one VPS, I'm not sure if this is a good idea, so can you give me some recommendations on this as well please.