Browse Source
feat(postgres-backup-s3): update AWS CLI to v2; allow support for multiple databases; allow support for defining sensitive env vars in files (eg Docker secrets)
feat(postgres-backup-s3): update AWS CLI to v2; allow support for multiple databases; allow support for defining sensitive env vars in files (eg Docker secrets)
AWS CLI updated to v2; python removed; glibc added Added support for multiple databases (note POSTGRES_DATABASE env var is deprecated and replaced by POSTGRES_DATABASES) -- this means this version of the docker image is not backward-compatible with previosu releases. Added support for _FILE env vars for sensitive values. This allows using the image with Docker secrets. For example, ``` service: postgres-backup environment: POSTGRES_PASSWORD_FILE=/run/secrets/postgres-password ... secrets: - postgres-password ```pull/135/head
Olivier Pichon
4 years ago
4 changed files with 121 additions and 45 deletions
-
57postgres-backup-s3/Dockerfile
-
22postgres-backup-s3/README.md
-
62postgres-backup-s3/backup.sh
-
25postgres-backup-s3/install.sh
@ -1,25 +1,56 @@ |
|||
FROM alpine:3.9 |
|||
LABEL maintainer="Johannes Schickling <schickling.j@gmail.com>" |
|||
FROM alpine:3.13 |
|||
LABEL maintainer="Dzango Technologies Limited <info@dzangolab.com>" |
|||
|
|||
ADD install.sh install.sh |
|||
RUN sh install.sh && rm install.sh |
|||
ENV GLIBC_VER=2.33-r0 |
|||
|
|||
ENV POSTGRES_DATABASE **None** |
|||
# install glibc compatibility for alpine |
|||
RUN apk --no-cache add \ |
|||
binutils \ |
|||
curl \ |
|||
&& curl -sL https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub -o /etc/apk/keys/sgerrand.rsa.pub \ |
|||
&& curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-${GLIBC_VER}.apk \ |
|||
&& curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-bin-${GLIBC_VER}.apk \ |
|||
&& curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-i18n-${GLIBC_VER}.apk \ |
|||
&& apk add --no-cache \ |
|||
glibc-${GLIBC_VER}.apk \ |
|||
glibc-bin-${GLIBC_VER}.apk \ |
|||
glibc-i18n-${GLIBC_VER}.apk \ |
|||
postgresql \ |
|||
&& /usr/glibc-compat/bin/localedef -i en_US -f UTF-8 en_US.UTF-8 \ |
|||
&& curl -sL https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscliv2.zip \ |
|||
&& unzip awscliv2.zip \ |
|||
&& aws/install \ |
|||
&& rm -rf \ |
|||
awscliv2.zip \ |
|||
aws \ |
|||
/usr/local/aws-cli/v2/*/dist/aws_completer \ |
|||
/usr/local/aws-cli/v2/*/dist/awscli/data/ac.index \ |
|||
/usr/local/aws-cli/v2/*/dist/awscli/examples \ |
|||
glibc-*.apk \ |
|||
&& curl -L --insecure https://github.com/odise/go-cron/releases/download/v0.0.6/go-cron-linux.gz | zcat > /usr/local/bin/go-cron \ |
|||
&& chmod u+x /usr/local/bin/go-cron \ |
|||
&& apk --no-cache del \ |
|||
binutils \ |
|||
curl \ |
|||
&& rm -rf /var/cache/apk/* |
|||
|
|||
ADD run.sh run.sh |
|||
ADD backup.sh backup.sh |
|||
|
|||
ENV POSTGRES_DATABASES **None** |
|||
ENV POSTGRES_EXTRA_OPTS '' |
|||
ENV POSTGRES_HOST **None** |
|||
ENV POSTGRES_PASSWORD **None** |
|||
ENV POSTGRES_PORT 5432 |
|||
ENV POSTGRES_USER **None** |
|||
ENV POSTGRES_PASSWORD **None** |
|||
ENV POSTGRES_EXTRA_OPTS '' |
|||
ENV S3_ACCESS_KEY_ID **None** |
|||
ENV S3_SECRET_ACCESS_KEY **None** |
|||
ENV S3_BUCKET **None** |
|||
ENV S3_REGION us-west-1 |
|||
ENV S3_PATH 'backup' |
|||
ENV S3_ENDPOINT **None** |
|||
ENV S3_FILENAME **None** |
|||
ENV S3_PREFIX 'backup' |
|||
ENV S3_REGION us-west-1 |
|||
ENV S3_S3V4 no |
|||
ENV S3_SECRET_ACCESS_KEY **None** |
|||
ENV SCHEDULE **None** |
|||
|
|||
ADD run.sh run.sh |
|||
ADD backup.sh backup.sh |
|||
|
|||
CMD ["sh", "run.sh"] |
@ -1,25 +0,0 @@ |
|||
#! /bin/sh |
|||
|
|||
# exit if a command fails |
|||
set -e |
|||
|
|||
|
|||
apk update |
|||
|
|||
# install pg_dump |
|||
apk add postgresql |
|||
|
|||
# install s3 tools |
|||
apk add python py2-pip |
|||
pip install awscli |
|||
apk del py2-pip |
|||
|
|||
# install go-cron |
|||
apk add curl |
|||
curl -L --insecure https://github.com/odise/go-cron/releases/download/v0.0.6/go-cron-linux.gz | zcat > /usr/local/bin/go-cron |
|||
chmod u+x /usr/local/bin/go-cron |
|||
apk del curl |
|||
|
|||
|
|||
# cleanup |
|||
rm -rf /var/cache/apk/* |
Write
Preview
Loading…
Cancel
Save
Reference in new issue