-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Hello,
I have read your comment on stackoverflow and the script you published here.
You write sth. about:
Proper entrypoint script can be written as almost universal way of processing secrets, because we can pass original image entrypoint as argument to our new entrypoint script so original image "decorator" is doing it's own work after we prepare container with our script.
But I don‘t see how you have implemented this directly in the entrypoint script. I can see that you are creating a new Dockerfile and do something there.
This is not what I want. I actually want to have a entrypoint script that I can use in any docker-compose file I have converts my ENV_VAR_FILE to ENV_VAR but then executes any entrypoint or cmd that is included in the image itself.
But maybe this is just possible by creating a new Dockerfile??
calibre.yml
version: '3.8'
services:
calibre:
image: lucapisciotta/calibre
container_name: calibre
user: ${PUID}:${PGID}
entrypoint: ./entrypoint.sh
env_file: calibre.env
volumes:
- /srv/mergerfs/NAS/Media/Calibre-Library:/books
restart: unless-stopped
networks:
- swag
secrets:
- admin_password
secrets:
admin_password:
file: ./admin_password
networks:
swag:
external: truecalibre.env
ADMIN_PASSWORD_FILE=/run/secrets/admin_password
# https://medium.com/@adrian.gheorghe.dev/using-docker-secrets-in-your-environment-variables-7a0609659aab
ENABLE_AUTH=true
TZ=Europe/Berli
entrypoint.sh (is not your script, but similiar and actually does not work…)
#!/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 "ADMIN_PASSWORD