Added .pass file build logic

This commit is contained in:
Paulino Padial 2018-01-23 18:12:33 +01:00
parent 6350a17178
commit 77f774d489
2 changed files with 29 additions and 2 deletions

View File

@ -17,7 +17,7 @@ ADD docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
# Volumes declaration
VOLUME ["/backup", "/scripts"]
VOLUME ["/backup"]
# Start the container process
ENTRYPOINT ["/docker-entrypoint.sh"]

View File

@ -1,4 +1,31 @@
#!/bin/sh
# Execute cron with parameters
# Logic for Password file required
# If PASSWORD_SECRET env var is defined, search for the /run/secrets/${PASSWORD_SECRET} and read the content
# If PASSWORD_SECRET is not defined, use PASSWORD env variable
# The idea, as specified in the software:
# create a file $HOME/.pgpass containing a line like this
# hostname:*:*:dbuser:dbpass
# replace hostname with the value of DBHOST and postgres with
# the value of USERNAME
PASSPHRASE=""
if [ "${PASSWORD_SECRET}" ]; then
if [ -f "/run/secrets/${PASSWORD_SECRET}" ]; then
PASSPHRASE = $(cat /run/secrets/${PASSWORD_SECRET})
else
echo "ERROR: Secret file not found in /run/secrets/${PASSWORD_SECRET}"
echo "Please verify your docker secrets configuration."
exit 1
fi
else
PASSPHRASE = ${PASSWORD}
fi
# Create the file
cat <<-EOF > ${HOME}/.pgpass
${DBHOST}:*:*:${USERNAME}:${PASSPHRASE}
EOF
# Execute cron with parameters (autopostgresql script is under /etc/cron.daily)
exec cron -f -l ${LOG_LEVEL:-8}