Compare commits

...

2 Commits

Author SHA1 Message Date
3wc bcc890338b Add volume mount for data persistence
continuous-integration/drone/push Build is failing Details
2023-01-22 19:26:20 -08:00
3wc 928dc24cb3 Use a secret for ADMIN_PASSWORD 2023-01-22 11:27:38 -08:00
4 changed files with 73 additions and 1 deletions

View File

@ -4,3 +4,5 @@ DOMAIN=filestash.example.com
## Domain aliases
#EXTRA_DOMAINS=', `www.filestash.example.com`'
LETS_ENCRYPT_ENV=production
SECRET_ADMIN_PASSWORD_VERSION=v1

1
abra.sh Normal file
View File

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

View File

@ -6,6 +6,10 @@ services:
- proxy
environment:
- APPLICATION_URL=$DOMAIN
# NOTE(3wc): See note below
# - ADMIN_PASSWORD_FILE=/run/secrets/admin_password
volumes:
- "filestash_state:/app/data/state/"
deploy:
restart_policy:
condition: on-failure
@ -19,8 +23,30 @@ 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}"
- coop-cloud.${STACK_NAME}.app.version=e02267d-07d7189c
# NOTE(3wc): Attempt to use secrets, need to bcrypt, more later
# secrets:
# - admin_password
# configs:
# - source: entrypoint_conf
# target: /docker-entrypoint.sh
# mode: 0555
# entrypoint: ['/docker-entrypoint.sh']
secrets:
admin_password:
external: true
name: ${STACK_NAME}_admin_password_${SECRET_ADMIN_PASSWORD_VERSION}
networks:
proxy:
external: true
volumes:
filestash_state:
configs:
entrypoint_conf:
name: ${STACK_NAME}_entrypoint_conf_${ENTRYPOINT_CONF_VERSION}
file: entrypoint.sh.tmpl
template_driver: golang

43
entrypoint.sh.tmpl Normal file
View File

@ -0,0 +1,43 @@
#!/usr/bin/env bash
file_env() {
# 3wc: Load $VAR_FILE into $VAR - useful for secrets. See
# https://medium.com/@adrian.gheorghe.dev/using-docker-secrets-in-your-environment-variables-7a0609659aab
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"
}
load_vars() {
file_env "ADMIN_PASSWORD"
}
main() {
set -eu
load_vars
}
main
# 3wc: `source /docker-entrypoint2.sh -e` to load ADMIN_PASSWORD for CLI scripts
if [ ! "${1-}" == "-e" ]; then
# 3wc: upstream ENTRYPOINT
# https://github.com/hedgedoc/container/blob/master/alpine/Dockerfile
/app/filestash
fi
set +eu