docker-compose: store default db passwords in .env.docker

and have redis use a password as well
This commit is contained in:
Alexandra Dunn 2021-01-27 11:44:14 -08:00
parent 10ca7ac052
commit 927ef3b057
2 changed files with 20 additions and 18 deletions

View file

@ -56,11 +56,16 @@ MAIL_ENCRYPTION=null
## Databases (MySQL) ## Databases (MySQL)
DB_CONNECTION=mysql DB_CONNECTION=mysql
DB_HOST=127.0.0.1 DB_DATABASE=pixelfed_prod
DB_HOST=db
DB_PASSWORD=pixelfed_db_pass
DB_PORT=3306 DB_PORT=3306
DB_DATABASE=pixelfed
DB_USERNAME=pixelfed DB_USERNAME=pixelfed
DB_PASSWORD=pixelfed # pass the same values to the db itself
MYSQL_DATABASE=pixelfed_prod
MYSQL_PASSWORD=pixelfed_db_pass
MYSQL_RANDOM_ROOT_PASSWORD=true
MYSQL_USER=pixelfed
## Databases (Postgres) ## Databases (Postgres)
#DB_CONNECTION=pgsql #DB_CONNECTION=pgsql
@ -74,7 +79,7 @@ DB_PASSWORD=pixelfed
REDIS_CLIENT=phpredis REDIS_CLIENT=phpredis
REDIS_SCHEME=tcp REDIS_SCHEME=tcp
REDIS_HOST=redis REDIS_HOST=redis
REDIS_PASSWORD=null REDIS_PASSWORD=redis_password
REDIS_PORT=6379 REDIS_PORT=6379
REDIS_DATABASE=0 REDIS_DATABASE=0

View file

@ -11,7 +11,6 @@ version: '3'
# if the volumes are properly shared between cluster members. # if the volumes are properly shared between cluster members.
services: services:
## App and Worker ## App and Worker
app: app:
# Comment to use dockerhub image # Comment to use dockerhub image
@ -21,11 +20,10 @@ services:
image: pixelfed image: pixelfed
restart: unless-stopped restart: unless-stopped
env_file: env_file:
- ./.env.docker - .env.docker
volumes: volumes:
- "app-storage:/var/www/storage" - app-storage:/var/www/storage
- "app-bootstrap:/var/www/bootstrap" - app-bootstrap:/var/www/bootstrap
- "./.env.docker:/var/www/.env"
networks: networks:
- external - external
- internal - internal
@ -42,10 +40,10 @@ services:
image: pixelfed image: pixelfed
restart: unless-stopped restart: unless-stopped
env_file: env_file:
- ./.env.docker - .env.docker
volumes: volumes:
- "app-storage:/var/www/storage" - app-storage:/var/www/storage
- "app-bootstrap:/var/www/bootstrap" - app-bootstrap:/var/www/bootstrap
networks: networks:
- external - external
- internal - internal
@ -61,17 +59,16 @@ services:
networks: networks:
- internal - internal
command: --default-authentication-plugin=mysql_native_password command: --default-authentication-plugin=mysql_native_password
environment: env_file:
- MYSQL_DATABASE=pixelfed - .env.docker
- MYSQL_USER=${DB_USERNAME}
- MYSQL_PASSWORD=${DB_PASSWORD}
- MYSQL_RANDOM_ROOT_PASSWORD=true
volumes: volumes:
- "db-data:/var/lib/mysql" - "db-data:/var/lib/mysql"
redis: redis:
image: redis:5-alpine image: redis:5-alpine
restart: unless-stopped restart: unless-stopped
env_file:
- .env.docker
volumes: volumes:
- "redis-data:/data" - "redis-data:/data"
networks: networks: