Update `docker-compose.yml` postgres example
Signed-off-by: mervyn <6359152+reply2future@users.noreply.github.com>pull/16392/head
parent
907bc79eac
commit
9c80525afa
|
@ -0,0 +1,93 @@
|
|||
# This compose file is compatible with Compose itself, it might need some
|
||||
# adjustments to run properly with stack.
|
||||
|
||||
version: '3'
|
||||
|
||||
x-pg-env: &pg_env
|
||||
POSTGRES_USER: synapse
|
||||
POSTGRES_PASSWORD: changeme
|
||||
POSTGRES_DB: synapse
|
||||
|
||||
services:
|
||||
|
||||
# use this container to generate the config file and then exit
|
||||
synapse-init:
|
||||
image: matrixdotorg/synapse:latest
|
||||
container_name: synapse-init
|
||||
entrypoint: 'bash'
|
||||
command: "-c './start.py generate && ./start.py migrate_config'"
|
||||
volumes:
|
||||
- synapse_data:/data
|
||||
environment:
|
||||
# more environment variables are available in the project directory `./docker/conf/homeserver.yaml`
|
||||
SYNAPSE_SERVER_NAME: 'changeme.com' # change to your server name
|
||||
SYNAPSE_REPORT_STATS: 'yes'
|
||||
SYNAPSE_NO_TLS: 'yes'
|
||||
POSTGRES_HOST: 'db'
|
||||
<<: *pg_env
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
|
||||
synapse:
|
||||
image: matrixdotorg/synapse:latest
|
||||
# Since synapse does not retry to connect to the database, restart upon
|
||||
# failure
|
||||
restart: unless-stopped
|
||||
# See the readme for a full documentation of the environment settings
|
||||
# NOTE: You must edit homeserver.yaml to use postgres, it defaults to sqlite
|
||||
environment:
|
||||
- SYNAPSE_CONFIG_PATH=/data/homeserver.yaml
|
||||
volumes:
|
||||
# You may either store all the files in a local folder
|
||||
- synapse_data:/data
|
||||
# .. or you may split this between different storage points
|
||||
# - ./files:/data
|
||||
# - /path/to/ssd:/data/uploads
|
||||
# - /path/to/large_hdd:/data/media
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
synapse-init:
|
||||
# more information about condition https://github.com/compose-spec/compose-spec/blob/master/05-services.md#long-syntax-1
|
||||
condition: service_completed_successfully
|
||||
ports:
|
||||
# http port, you could use `8448` if you unset `SYNAPSE_NO_TLS` above the `synapse-init` container
|
||||
- 8008:8008/tcp
|
||||
|
||||
db:
|
||||
image: docker.io/postgres:12-alpine
|
||||
# Change that password, of course!
|
||||
environment:
|
||||
# ensure the database gets created correctly
|
||||
# https://matrix-org.github.io/synapse/latest/postgres.html#set-up-database
|
||||
POSTGRES_INITDB_ARGS: --encoding=UTF-8 --lc-collate=C --lc-ctype=C
|
||||
<<: *pg_env
|
||||
volumes:
|
||||
# You may store the database tables in a local folder..
|
||||
- pg_data:/var/lib/postgresql/data
|
||||
# .. or store them on some high performance storage for better results
|
||||
# - /path/to/ssd/storage:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready", "-d", "synapse"]
|
||||
interval: 30s
|
||||
timeout: 60s
|
||||
retries: 5
|
||||
start_period: 80s
|
||||
|
||||
volumes:
|
||||
synapse_data:
|
||||
# you need to set the local path to your data directory here or you would lost the data if you clean the volume
|
||||
driver: local
|
||||
driver_opts:
|
||||
type: 'none'
|
||||
o: 'bind'
|
||||
device: '${PWD}/deploy_data' # change the `device` to your local path
|
||||
|
||||
pg_data:
|
||||
# you need to set the local path to your data directory here or you would lost the data if you clean the volume
|
||||
driver: local
|
||||
driver_opts:
|
||||
type: 'none'
|
||||
o: 'bind'
|
||||
device: '${PWD}/pg_data' # change the `device` to your local path
|
Loading…
Reference in New Issue