-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (44 loc) · 1.91 KB
/
Dockerfile
File metadata and controls
54 lines (44 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# 📄 Dockerfile
#── Builder stage ─────────────────────────────────────────────────────────────
FROM golang:1.24-bookworm AS builder
ARG TARGETOS TARGETARCH
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
go build -o hyper-backup main.go
# ── Final stage ───────────────────────────────────────────────────────────────
FROM debian:bookworm AS final
ARG MONGO_TOOLS_VERSION=100.12.0
ARG UID=1001
ARG GID=1001
ARG TZ=Asia/Seoul
# System user setup
RUN set -eux; \
groupadd --gid ${GID} hyper-backup; \
useradd --uid ${UID} --gid ${GID} --home-dir /home/hyper-backup --create-home hyper-backup
ENV TZ=${TZ}
WORKDIR /home/hyper-backup
# Dependencies
RUN apt-get update && apt-get install -y \
ca-certificates curl wget gnupg lsb-release gosu \
rsync rclone default-mysql-client postgresql-client \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# MongoDB Tools install
RUN set -eux; \
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
case "${dpkgArch}" in \
amd64) ARCH_TAG="x86_64";; \
arm64) ARCH_TAG="arm64";; \
*) echo "Unsupported arch ${dpkgArch}"; exit 1;; \
esac; \
URL="https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2404-${ARCH_TAG}-${MONGO_TOOLS_VERSION}.tgz"; \
TMPDIR="$(mktemp -d)"; \
curl -fsSL "${URL}" | tar -xz -C "${TMPDIR}"; \
mv "${TMPDIR}"/mongodb-database-tools-*/bin/* /usr/local/bin/; \
rm -rf "${TMPDIR}"
# Copy our hyper-backup binary into PATH
COPY --link --from=builder /app/hyper-backup /usr/bin/hyper-backup
COPY --link entrypoint /usr/bin/entrypoint
ENTRYPOINT ["entrypoint"]