add postgres service for backend database

This commit is contained in:
James 2022-01-29 00:15:18 +00:00
parent 30b2101099
commit e658d71853
3 changed files with 28 additions and 4 deletions

View File

@ -1,4 +1,5 @@
IMAGE_TAG=latest # synapse
SYNAPSE_IMAGE_TAG=latest
SERVER_NAME=localhost SERVER_NAME=localhost
HTTP_PORT=8008 HTTP_PORT=8008
CONFIG_DIR=/data CONFIG_DIR=/data
@ -6,3 +7,5 @@ CONFIG_FILE_NAME=homeserver.yaml
UID=991 UID=991
GID=991 GID=991
TZ=UTC TZ=UTC
POSTGRESQL_IMAGE_TAG=14

1
.gitignore vendored
View File

@ -1 +1,2 @@
.env .env
postgres_password.txt

View File

@ -1,9 +1,27 @@
volumes: volumes:
synapse-data: synapse-data:
postgres:
secrets:
postgres_password:
file: ./postgres_password.txt
services: services:
postgres:
image: postgres:${POSTGRESQL_IMAGE_TAG}
restart: unless-stopped
volumes:
- postgres:/var/lib/postgresql/data:rw
secrets:
- postgres_password
environment:
POSTGRES_DB: synapse
POSTGRES_USER: synapse_user
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
POSTGRES_INITDB_ARGS: --encoding=UTF8 --locale=C
synapse: synapse:
image: matrixdotorg/synapse:${IMAGE_TAG} image: matrixdotorg/synapse:${SYNAPSE_IMAGE_TAG}
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- synapse-data:${CONFIG_DIR} - synapse-data:${CONFIG_DIR}
@ -15,3 +33,5 @@ services:
TZ: ${TZ} TZ: ${TZ}
ports: ports:
- ${HTTP_PORT}:8008 - ${HTTP_PORT}:8008
depends_on:
- postgres