entrypoint for env vars
This commit is contained in:
parent
1cd075d8a2
commit
4b34097657
16
compose.yml
16
compose.yml
|
@ -30,6 +30,11 @@ services:
|
||||||
- internal
|
- internal
|
||||||
ports:
|
ports:
|
||||||
- "4000:4000" # make sure this is commented in production
|
- "4000:4000" # make sure this is commented in production
|
||||||
|
entrypoint: "/docker-entrypoint.sh"
|
||||||
|
configs:
|
||||||
|
- source: app_entrypoint
|
||||||
|
target: /docker-entrypoint.sh
|
||||||
|
mode: 0555
|
||||||
deploy:
|
deploy:
|
||||||
restart_policy:
|
restart_policy:
|
||||||
condition: on-failure
|
condition: on-failure
|
||||||
|
@ -74,6 +79,11 @@ services:
|
||||||
- "search-data:/data.ms"
|
- "search-data:/data.ms"
|
||||||
networks:
|
networks:
|
||||||
- internal
|
- internal
|
||||||
|
entrypoint: ["/tini", "--", "/docker-entrypoint.sh"]
|
||||||
|
configs:
|
||||||
|
- source: app_entrypoint
|
||||||
|
target: /docker-entrypoint.sh
|
||||||
|
mode: 0555
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
db-data:
|
db-data:
|
||||||
|
@ -85,6 +95,12 @@ networks:
|
||||||
external: true
|
external: true
|
||||||
internal:
|
internal:
|
||||||
|
|
||||||
|
configs:
|
||||||
|
app_entrypoint:
|
||||||
|
name: ${STACK_NAME}_app_entrypoint_${APP_ENTRYPOINT_VERSION}
|
||||||
|
file: entrypoint.sh.tmpl
|
||||||
|
template_driver: golang
|
||||||
|
|
||||||
secrets:
|
secrets:
|
||||||
postgres_password:
|
postgres_password:
|
||||||
external: true
|
external: true
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
#!/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 "MEILI_MASTER_KEY"
|
Loading…
Reference in New Issue