chore: update environment variables in compose.yaml

- Replace hardcoded DATABASE_URL and RAILS_MASTER_KEY with
  environment variables.
- Change POSTGRES_PASSWORD to utilize an environment
  variable instead of a hardcoded value.

These changes enhance security by ensuring sensitive
information is not exposed in the configuration files,
allowing for better practices in managing environment
variables.
This commit is contained in:
songtianlun 2025-01-23 10:22:07 +08:00
parent 91e62234b4
commit af95c2e55f

View File

@ -7,8 +7,8 @@ services:
# - "3000:3000" # - "3000:3000"
environment: environment:
- RAILS_ENV=production - RAILS_ENV=production
- DATABASE_URL=postgresql://postgres:xxx@db:5432/db - DATABASE_URL=postgresql://postgres:${PG_PASSWORD}@db:5432/db
- RAILS_MASTER_KEY=xxx - RAILS_MASTER_KEY=${RAILS_MASTER_KEY}
- REDIS_URL=redis://redis:6379/0 - REDIS_URL=redis://redis:6379/0
depends_on: depends_on:
- db - db
@ -19,8 +19,8 @@ services:
command: bundle exec sidekiq command: bundle exec sidekiq
environment: environment:
- RAILS_ENV=production - RAILS_ENV=production
- DATABASE_URL=postgresql://postgres:xxx@db:5432/db - DATABASE_URL=postgresql://postgres:${PG_PASSWORD}@db:5432/db
- RAILS_MASTER_KEY=xxx - RAILS_MASTER_KEY=${RAILS_MASTER_KEY}
- REDIS_URL=redis://redis:6379/0 - REDIS_URL=redis://redis:6379/0
depends_on: depends_on:
- db - db
@ -31,7 +31,7 @@ services:
volumes: volumes:
- ../taw_data/pg:/var/lib/postgresql/data - ../taw_data/pg:/var/lib/postgresql/data
environment: environment:
- POSTGRES_PASSWORD=xxx - POSTGRES_PASSWORD=${PG_PASSWORD}
- POSTGRES_DB=db - POSTGRES_DB=db
redis: redis: