commit 71ee8bbce80cba5fa07c51ea606de98a8d0fef1a Author: Amras Date: Sun Sep 3 20:47:41 2023 +0000 initial commit diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..51f5d62 --- /dev/null +++ b/.env.sample @@ -0,0 +1,30 @@ +TYPE=szurubooru + +# Database credentials +POSTGRES_USER=szuru + +# This shows up on the homescreen, indicating build information +BUILD_INFO=latest + +# Port to expose HTTP service +# Set to 127.0.0.1:8080 if you wish to reverse-proxy the docker's port, +# otherwise the port specified here will be publicly accessible +PORT=8080 + +# How many waitress threads to start +# 4 is the default amount of threads. If you experience performance +# degradation with a large number of posts, increasing this may +# improve performance, since waitress is most likely clogging up with Tasks. +THREADS=4 + +# URL base to run szurubooru under +# See "Additional Features" section in INSTALL.md +BASE_URL=/ + +# Directory to store image data +MOUNT_DATA=/var/local/szurubooru/data + +# Directory to store database files +MOUNT_SQL=/var/local/szurubooru/sql +SECRET_DB_PASSWORD_VERSION: v1 +SECRET_SMTP_PASSWORD_VERSION: v1 diff --git a/abra.sh b/abra.sh new file mode 100644 index 0000000..8875f2e --- /dev/null +++ b/abra.sh @@ -0,0 +1,2 @@ +export SERVER_CONFIG_VERSION=v1 +export SERVER_ENTRYPOINT_VERSION=v1 diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..d14ecea --- /dev/null +++ b/compose.yml @@ -0,0 +1,76 @@ +version: '3.8' + +services: + app: + image: szurubooru/client:2.5 + depends_on: + - server + environment: + - BACKEND_HOST=server + - BASE_URL + volumes: + - app:/data:ro + deploy: + labels: + - "traefik.enable=true" + - "traefik.docker.network=proxy" + - "traefik.http.services.${STACK_NAME}.loadbalancer.server.port=80" + - "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`)" + - "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}" + - "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure" + - "coop-cloud.${STACK_NAME}.version=0.0.1+2.5" + + server: + image: szurubooru/server:2.5 + depends_on: + - sql + volumes: + - server:/data + - "./config.yaml:/opt/app/config.yaml" + configs: + - source: server_config + target: /opt/app/config.yaml + - source: server_entrypoint + target: /docker-entrypoint.sh + mode: 0555 + secrets: + - db_password + - smtp_password + environment: + - POSTGRES_HOST=sql + - POSTGRES_USER=${DB_USER} + - POSTGRES_PASSWORD_FILE=/run/secrets/db_password + - THREADS + + sql: + image: postgres:11-alpine + secrets: + - db_password + environment: + - POSTGRES_USER=${DB_USER} + - POSTGRES_PASSWORD_FILE=/run/secrets/db_password + volumes: + - postgres:/var/lib/postgresql/data + +configs: + server_config: + name: ${STACK_NAME}_server_config_${SERVER_CONFIG_VERSION} + file: server.conf.tml + template_driver: golang + server_entrypoint: + name: ${STACK_NAME}_server_entrypoint_${SERVER_ENTRYPOINT_VERSION} + file: entrypoint.sh.tmpl + template_driver: golang + +secrets: + db_password: + external: true + name: ${STACK_NAME}_db_password_${SECRET_DB_PASSWORD_VERSION} + smtp_password: + external: true + name: ${STACK_NAME}_smtp_password_${SECRET_SMTP_PASSWORD_VERSION} + +volumes: + app: + server: + postgres: diff --git a/entrypoint.sh.tmpl b/entrypoint.sh.tmpl new file mode 100644 index 0000000..2f88661 --- /dev/null +++ b/entrypoint.sh.tmpl @@ -0,0 +1,28 @@ +#!/bin/bash + +set -e + +file_env() { + local var="$1" + local fileVar="${var}_FILE" + local def="${2:-}" + + if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then + echo >&2 "error: both $var and $fileVar are set (but are exclusive)" + exit 1 + fi + + local val="$def" + if [ "${!var:-}" ]; then + val="${!var}" + elif [ "${!fileVar:-}" ]; then + val="$(< "${!fileVar}")" + fi + + export "$var"="$val" + unset "$fileVar" +} + +# for sidekiq service bundle exec env var threading +file_env "SMTP_PASSWORD" +file_env "DB_PASSWORD" diff --git a/server.conf.tmpl b/server.conf.tmpl new file mode 100644 index 0000000..8ccd7db --- /dev/null +++ b/server.conf.tmpl @@ -0,0 +1,11 @@ +name: $NAME +domain: $DOMAIN +smtp: + host: $SMTP_HOST + port: $SMTP_PORT + user: $SMTP_USER + pass: {{ secret "smtp_password" }} + from: $SMTP_FROM + +contact_email: $CONTACT_EMAIL +