docker-mysql-cron-backup/Dockerfile

48 lines
1.3 KiB
Text
Raw Normal View History

FROM golang:1.20.4-alpine3.18 AS binary
RUN apk -U add openssl git
ARG DOCKERIZE_VERSION=v0.7.0
WORKDIR /go/src/github.com/jwilder
2021-05-09 11:28:53 +02:00
RUN git clone https://github.com/jwilder/dockerize.git && \
cd dockerize && \
git checkout ${DOCKERIZE_VERSION}
WORKDIR /go/src/github.com/jwilder/dockerize
ENV GO111MODULE=on
RUN go mod tidy
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o /go/bin/dockerize .
FROM alpine:3.18.4
2017-09-11 09:36:38 +02:00
LABEL maintainer "Fco. Javier Delgado del Hoyo <frandelhoyo@gmail.com>"
RUN apk add --update \
tzdata \
bash \
mysql-client \
gzip \
openssl \
2021-05-13 20:30:26 +02:00
mariadb-connector-c && \
rm -rf /var/cache/apk/*
COPY --from=binary /go/bin/dockerize /usr/local/bin
2018-11-08 14:46:39 +01:00
ENV CRON_TIME="0 3 * * sun" \
MYSQL_HOST="mysql" \
2018-11-09 15:55:53 +01:00
MYSQL_PORT="3306" \
TIMEOUT="10s" \
MYSQLDUMP_OPTS="--quick"
COPY ["run.sh", "backup.sh", "restore.sh", "/delete.sh", "/"]
2021-05-09 11:28:53 +02:00
RUN mkdir /backup && \
chmod 777 /backup && \
chmod 755 /run.sh /backup.sh /restore.sh /delete.sh && \
touch /mysql_backup.log && \
2021-05-09 11:28:53 +02:00
chmod 666 /mysql_backup.log
VOLUME ["/backup"]
2023-01-05 11:55:04 +01:00
HEALTHCHECK --interval=2s --retries=1800 \
2023-01-20 12:04:19 +01:00
CMD stat /HEALTHY.status || exit 1
2023-01-05 11:55:04 +01:00
CMD dockerize -wait tcp://${MYSQL_HOST}:${MYSQL_PORT} -timeout ${TIMEOUT} /run.sh