with command

This commit is contained in:
val 2025-06-14 11:18:17 +02:00
parent 4954511131
commit 3c467307fb
No known key found for this signature in database
GPG Key ID: 650507CF2C02830C
5 changed files with 63 additions and 6 deletions

View File

@ -1,3 +1,6 @@
#SECRET_DB_PASSWORD_VERSION=v1
#SECRET_SMTP_PASSWORD_VERSION=v1
TYPE=ghost TYPE=ghost
DOMAIN=ghost.example.com DOMAIN=ghost.example.com
@ -13,7 +16,6 @@ LETS_ENCRYPT_ENV=production
#MAIL_OPTIONS_PORT=587 #MAIL_OPTIONS_PORT=587
#MAIL_OPTIONS_SECURE=false #MAIL_OPTIONS_SECURE=false
#MAIL_OPTIONS_AUTH_USER=smtpuser@example.com #MAIL_OPTIONS_AUTH_USER=smtpuser@example.com
#MAIL_OPTIONS_AUTH_PASS=XXXX
## Matrix-Synapse-Redirection ## Matrix-Synapse-Redirection
# If you want to use Ghost on a TLD which you want to use as matrix server name as well # If you want to use Ghost on a TLD which you want to use as matrix server name as well

1
abra.sh Normal file
View File

@ -0,0 +1 @@
export GHOST_ENTRYPOINT_VERSION=v1

View File

@ -1,4 +1,3 @@
version: "3.8"
services: services:
app: app:
deploy: deploy:

View File

@ -1,4 +1,3 @@
version: "3.8"
services: services:
app: app:
image: ghost:5-alpine image: ghost:5-alpine
@ -7,8 +6,8 @@ services:
database__client: mysql database__client: mysql
database__connection__host: ${STACK_NAME}_db database__connection__host: ${STACK_NAME}_db
database__connection__user: root database__connection__user: root
database__connection__password: ghost
database__connection__database: ghost database__connection__database: ghost
database__connection__password_FILE: /run/secrets/db_password
url: https://$DOMAIN url: https://$DOMAIN
mail__transport: ${MAIL_TRANSPORT} mail__transport: ${MAIL_TRANSPORT}
mail__from: ${MAIL_FROM} mail__from: ${MAIL_FROM}
@ -16,9 +15,18 @@ services:
mail__options__port: ${MAIL_OPTIONS_PORT} mail__options__port: ${MAIL_OPTIONS_PORT}
mail__options__secure: ${MAIL_OPTIONS_SECURE} mail__options__secure: ${MAIL_OPTIONS_SECURE}
#mail__options__auth__user: ${MAIL_OPTIONS_AUTH_USER} #mail__options__auth__user: ${MAIL_OPTIONS_AUTH_USER}
#mail__options__auth__pass: ${MAIL_OPTIONS_AUTH_PASS} mail__options__auth__pass_FILE: /run/secrets/smtp_password
# contrary to the default mentioned in the linked documentation, this image defaults to NODE_ENV=production (so development mode needs to be explicitly specified if desired) # contrary to the default mentioned in the linked documentation, this image defaults to NODE_ENV=production (so development mode needs to be explicitly specified if desired)
#NODE_ENV: development #NODE_ENV: development
secrets:
- db_password
- smtp_password
configs:
- source: ghost_entrypoint
target: /abra-entrypoint.sh
mode: 0555
command: node current/index.js
entrypoint: /abra-entrypoint.sh
networks: networks:
- proxy - proxy
- backend - backend
@ -52,7 +60,9 @@ services:
networks: networks:
- backend - backend
environment: environment:
MYSQL_ROOT_PASSWORD: ghost MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_password
secrets:
- db_password
volumes: volumes:
- "mysql:/var/lib/mysql" - "mysql:/var/lib/mysql"
deploy: deploy:
@ -70,3 +80,16 @@ networks:
volumes: volumes:
mysql: mysql:
ghost_content: ghost_content:
secrets:
db_password:
name: ${STACK_NAME}_db_password_${SECRET_DB_PASSWORD_VERSION}
external: true
smtp_password:
external: true
name: ${STACK_NAME}_smtp_password_${SECRET_SMTP_PASSWORD_VERSION}
configs:
ghost_entrypoint:
name: ${STACK_NAME}_ghost_entrypoint_${GHOST_ENTRYPOINT_VERSION}
file: entrypoint.sh

32
entrypoint.sh Normal file
View File

@ -0,0 +1,32 @@
#!/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"
}
file_env "database__connection__password"
file_env "mail__options__auth__pass"
# upstream entrypoint https://github.com/docker-library/ghost/blob/master/5/alpine/Dockerfile
/usr/local/bin/docker-entrypoint.sh "$@"