Add docker entrypoint for loading secrets
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
7f508fc04b
commit
509b6b5e8b
32
docker-entrypoint.sh
Normal file
32
docker-entrypoint.sh
Normal file
@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
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 "TOKEN"
|
||||
file_env "MONGODB_PASSWORD"
|
||||
file_env "PAYLOAD_SECRET"
|
||||
|
||||
export MONGODB_URI="mongodb://$MONGODB_USER:$MONGODB_PASSWORD@$MONGODB_HOST:$MONGODB_PORT"
|
||||
|
||||
"$@"
|
@ -26,4 +26,6 @@ COPY --from=build /build/tsconfig.json ./tsconfig.json
|
||||
COPY --from=build /build/dist ./dist
|
||||
COPY --from=build /build/build ./build
|
||||
EXPOSE 3000
|
||||
COPY docker-entrypoint.sh /
|
||||
ENTRYPOINT /docker-entrypoint.sh
|
||||
CMD ["yarn", "serve"]
|
Loading…
Reference in New Issue
Block a user