6 Commits

3 changed files with 104 additions and 94 deletions
+23 -30
View File
@@ -1,20 +1,38 @@
TYPE=bonfire
LETS_ENCRYPT_ENV=production
# choose what flavour of Bonfire to run
FLAVOUR=social
APP_VERSION=latest
# enter your instance's domain name
DOMAIN=bonfire.example.com
# DO NOT CHANGE DOMAIN AFTER DEPLOYMENT! WILL BREAK FEDERATION!!
## Domain aliases
#EXTRA_DOMAINS=', `www.bonfire.example.com`'
# enable abra backups
ENABLE_BACKUPS=true
COMPOSE_FILE="compose.yml"
# ====================================
# Database config
COMPOSE_FILE="$COMPOSE_FILE:compose.postgres.yml"
SECRET_POSTGRES_PASSWORD_VERSION=v1
# choose what extra services you want to run
COMPOSE_FILE="compose.yml:compose.meilisearch.yml"
COMPOSE_FILE="$COMPOSE_FILE:compose.meilisearch.yml"
# To use Sonic instead of Meilisearch as the search backend:
# COMPOSE_FILE="compose.yml:compose.sonic.yml"
# COMPOSE_FILE="$COMPOSE_FILE:compose.sonic.yml"
# Enable `compose.mail.yml` to set secrets for sending emails (remember to also include your chosen search backend's compose file):
# COMPOSE_FILE="compose.yml:compose.mail.yml"
# COMPOSE_FILE="$COMPOSE_FILE:compose.mail.yml"
# Enable `compose.postgres.tune.yml` for Postgres tuning (can only be enabled *after* your instance already is deployed and working) (and remember to also include your chosen search backend and mailer's compose files)
# COMPOSE_FILE="compose.yml:compose.postgres.tune.yml"
# COMPOSE_FILE="$COMPOSE_FILE:compose.postgres.tune.yml"
APP_VERSION_FLAVOUR=${APP_VERSION}-${FLAVOUR}
# Different flavours/forks or architectures may require different builds of bonfire:
@@ -28,7 +46,7 @@ APP_DOCKER_IMAGE=bonfirenetworks/bonfire:${APP_VERSION_FLAVOUR}-amd64
DB_DOCKER_VERSION=17-3.5
# note that different flavours or architectures may require different postgres builds:
# For ARM or x86:
DB_DOCKER_IMAGE=ghcr.io/baosystems/postgis:${DB_DOCKER_VERSION}
DB_DOCKER_IMAGE=ghcr.io/baosystems/postgis
# for x86:
# DB_DOCKER_IMAGE=postgis/postgis:${DB_DOCKER_VERSION}-alpine
# multiarch (but doesn't have required Postgis extension)
@@ -36,17 +54,6 @@ DB_DOCKER_IMAGE=ghcr.io/baosystems/postgis:${DB_DOCKER_VERSION}
# TODO: maybe to use for Upgrading to a new Postgres version? (NOTE: does not work with postgis data)
# DB_DOCKER_IMAGE=pgautoupgrade/pgautoupgrade:16-alpine
# enter your instance's domain name
DOMAIN=bonfire.example.com
# DO NOT CHANGE DOMAIN AFTER DEPLOYMENT! WILL BREAK FEDERATION!!
## Domain aliases
#EXTRA_DOMAINS=', `www.bonfire.example.com`'
# enable abra backups
ENABLE_BACKUPS=true
# uncomment in order to NOT automatically change the database schema when you upgrade the app
# DISABLE_DB_AUTOMIGRATION=true
@@ -162,7 +169,6 @@ LIVE_DASHBOARD_LOGGER=false
# ====================================
# these secrets will be autogenerated/managed by abra and docker"
SECRET_POSTGRES_PASSWORD_VERSION=v1
SECRET_MEILI_MASTER_KEY_VERSION=v1
SECRET_SONIC_PASSWORD_VERSION=v1
SECRET_SEEDS_PW_VERSION=v1
@@ -172,16 +178,3 @@ SECRET_SECRET_KEY_BASE_VERSION=v1 # length=128
SECRET_SIGNING_SALT_VERSION=v1 # length=128
SECRET_ENCRYPTION_SALT_VERSION=v1 # length=128
# ====================================
# You should not have to edit any of the following ones:
APP_NAME=Bonfire
LANG=en_US.UTF-8
SEEDS_USER=root
ERLANG_COOKIE=bonfire_cookie
REPLACE_OS_VARS=true
LIVEVIEW_ENABLED=true
ACME_AGREE=true
SHOW_DEBUG_IN_DEV=true
LETS_ENCRYPT_ENV=production
HOSTNAME=$DOMAIN
#PLUG_SERVER=bandit
+68
View File
@@ -0,0 +1,68 @@
version: '3.8'
x-postgres-env: &postgres-env
POSTGRES_DB: bonfire_db
POSTGRES_USER: postgres
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
services:
app:
environment:
<<: *postgres-env
POSTGRES_HOST: ${STACK_NAME}_db
secrets:
- postgres_password
db:
image: ${DB_DOCKER_IMAGE:-ghcr.io/baosystems/postgis}:${DB_DOCKER_VERSION:-17-3.5}
command: >
postgres
-c max_connections=200
-c shared_buffers=${DB_MEMORY_LIMIT}MB
# -c shared_preload_libraries='pg_stat_statements'
# -c statement_timeout=1800000
# -c pg_stat_statements.track=all
#entrypoint: ['tail', '-f', '/dev/null'] # uncomment when the Postgres DB is corrupted and won't start
volumes:
- db-data:/var/lib/postgresql/data
- type: tmpfs
target: /dev/shm
tmpfs:
size: 1000000000
# about 1 GB in bytes
tmpfs:
- /tmp:size=${DB_MEMORY_LIMIT}M^
networks:
- internal
environment:
<<: *postgres-env
secrets:
- postgres_password
healthcheck:
test: ["CMD-SHELL", "pg_isready", "-U", "postgres"]
interval: 10s
timeout: 5s
retries: 5
deploy:
labels:
backupbot.backup: ${ENABLE_BACKUPS:-true}
backupbot.backup.pre-hook: "/pg_backup.sh backup"
backupbot.backup.volumes.db-data.path: "backup.sql"
backupbot.restore.post-hook: '/pg_backup.sh restore'
configs:
- source: pg_backup
target: /pg_backup.sh
mode: 0555
volumes:
db-data:
configs:
pg_backup:
name: ${STACK_NAME}_pg_backup_${PG_BACKUP_VERSION}
file: pg_backup.sh
secrets:
postgres_password:
external: true
name: ${STACK_NAME}_postgres_password_${SECRET_POSTGRES_PASSWORD_VERSION:-v1}
+13 -64
View File
@@ -12,23 +12,20 @@ services:
depends_on:
- db
environment:
- POSTGRES_HOST=${STACK_NAME}_db
- POSTGRES_USER=postgres
- POSTGRES_DB=bonfire_db
- PUBLIC_PORT=443
- MIX_ENV=prod
- HOSTNAME
- HOSTNAME=${DOMAIN}
- INSTANCE_DESCRIPTION
- DISABLE_DB_AUTOMIGRATION
- UPLOAD_LIMIT
- INVITE_KEY
- LANG
- SEEDS_USER
- ERLANG_COOKIE
- REPLACE_OS_VARS
- LIVEVIEW_ENABLED
- APP_NAME
- LANG=${LANG:-en_US.UTF-8}
- SEEDS_USER=${SEEDS_USER:-root}
- ERLANG_COOKIE=${ERLANG_COOKIE:-bonfire_cookie}
- REPLACE_OS_VARS=${REPLACE_OS_VARS:-true}
- LIVEVIEW_ENABLED=${LIVEVIEW_ENABLED:-true}
- APP_NAME={APP_NAME:-Bonfire}
- PLUG_SERVER
- WITH_LV_NATIVE
- WITH_IMAGE_VIX
@@ -115,7 +112,6 @@ services:
- IFRAME_ALLOWED_ORIGINS
secrets:
- postgres_password
- secret_key_base
- signing_salt
- encryption_salt
@@ -150,53 +146,12 @@ services:
#- "traefik.http.routers.${STACK_NAME}.middlewares=${STACK_NAME}-redirect"
#- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLForceHost=true"
#- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLHost=${DOMAIN}"
# healthcheck:
# test: ["CMD", "curl", "-f", "http://localhost"]
# interval: 30s
# timeout: 10s
# retries: 10
# start_period: 1m
db:
image: ${DB_DOCKER_IMAGE}
environment:
# - POSTGRES_PASSWORD
- POSTGRES_USER=postgres
- POSTGRES_DB=bonfire_db
- POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password
secrets:
- postgres_password
volumes:
- db-data:/var/lib/postgresql/data
- type: tmpfs
target: /dev/shm
tmpfs:
size: 1000000000
# about 1 GB in bytes ^
networks:
- internal
# shm_size: ${DB_MEMORY_LIMIT} # unsupported by docker swarm
tmpfs:
- /tmp:size=${DB_MEMORY_LIMIT}M
command: >
postgres
-c max_connections=200
-c shared_buffers=${DB_MEMORY_LIMIT}MB
# -c shared_preload_libraries='pg_stat_statements'
# -c statement_timeout=1800000
# -c pg_stat_statements.track=all
#entrypoint: ['tail', '-f', '/dev/null'] # uncomment when the Postgres DB is corrupted and won't start
deploy:
labels:
backupbot.backup: ${ENABLE_BACKUPS:-true}
# backupbot.backup.volumes.db-data: false
backupbot.backup.volumes.db-data.path: "backup.sql"
backupbot.backup.pre-hook: "/pg_backup.sh backup"
backupbot.restore.post-hook: '/pg_backup.sh restore'
configs:
- source: pg_backup
target: /pg_backup.sh
mode: 0555
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:4000"]
interval: 30s
timeout: 10s
retries: 10
start_period: 15s
volumes:
db-data:
@@ -213,14 +168,8 @@ configs:
name: ${STACK_NAME}_app_entrypoint_${APP_ENTRYPOINT_VERSION:-v3}
file: entrypoint.sh.tmpl
template_driver: golang
pg_backup:
name: ${STACK_NAME}_pg_backup_${PG_BACKUP_VERSION:-v4}
file: pg_backup.sh
secrets:
postgres_password:
external: true
name: ${STACK_NAME}_postgres_password_${SECRET_POSTGRES_PASSWORD_VERSION:-v1}
secret_key_base:
external: true
name: ${STACK_NAME}_secret_key_base_${SECRET_SECRET_KEY_BASE_VERSION:-v1}