mirror of
https://github.com/ChristianLempa/boilerplates.git
synced 2024-11-25 01:34:36 +01:00
feat: use Docker secrets for password
Using environment variables for secret data like passwords is an anti-pattern as they can easily leak. It's much safer to maintain the data as a file. To prevent accidental commits of the password file, we are adding a `.gitignore` file.
This commit is contained in:
parent
bb84e13b9a
commit
edf466c7c9
1
docker-compose/postgres/.gitignore
vendored
Normal file
1
docker-compose/postgres/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
secret.*
|
@ -6,7 +6,7 @@ services:
|
||||
image: docker.io/library/postgres:16.2
|
||||
environment:
|
||||
- POSTGRES_USER=${POSTGRES_USER}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||
- POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password
|
||||
# (Optional) when creating a new database
|
||||
# - POSTGRES_DB=${POSTGRES_DB}
|
||||
ports:
|
||||
@ -16,6 +16,8 @@ services:
|
||||
#
|
||||
# networks:
|
||||
# - yournetwork
|
||||
secrets:
|
||||
- postgres_password
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
restart: unless-stopped
|
||||
@ -27,6 +29,10 @@ services:
|
||||
# yournetwork:
|
||||
# external: true
|
||||
|
||||
secrets:
|
||||
postgres_password:
|
||||
file: secret.postgres_password.txt
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
driver: local
|
||||
|
Loading…
Reference in New Issue
Block a user