Dockerfile 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # build stage
  2. FROM golang:1.20 AS builder
  3. WORKDIR /app
  4. COPY . .
  5. RUN go env -w GO111MODULE=on \
  6. && make clean test build
  7. # build s3sync
  8. FROM golang:1.20 AS s3sync
  9. WORKDIR /src/
  10. RUN git clone --branch 2.55 https://github.com/larrabee/s3sync.git
  11. WORKDIR /src/s3sync
  12. ENV CGO_ENABLED 0
  13. COPY . ./
  14. RUN go mod tidy && \
  15. go build -o s3sync ./cli
  16. # final stage
  17. FROM debian:stable-slim
  18. LABEL name=backup-x
  19. LABEL url=https://github.com/jeessy2/backup-x
  20. RUN apt-get -y update \
  21. && apt-get install -y wget curl gpg gnupg2 software-properties-common apt-transport-https lsb-release ca-certificates
  22. # https://www.postgresql.org/download/linux/debian/
  23. RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' \
  24. && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
  25. && apt-get -y update
  26. RUN apt-get install -y postgresql-client-14 \
  27. && apt-get install -y default-mysql-client
  28. WORKDIR /app
  29. VOLUME /app/backup-x-files
  30. ENV TZ=Asia/Shanghai
  31. COPY --from=builder /app/backup-x /app/backup-x
  32. COPY --from=s3sync /src/s3sync/s3sync /usr/local/bin/s3sync
  33. EXPOSE 9977
  34. ENTRYPOINT ["/app/backup-x"]