Repository navigation
Expand file tree
/
Copy pathContainerfile
More file actions
70 lines (53 loc) · 2.74 KB
/
Copy pathContainerfile
File metadata and controls
70 lines (53 loc) · 2.74 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Global ARGs: single source of truth for base image versions
# renovate: datasource=docker depName=docker.io/library/golang
ARG go_version=1.27
# renovate: datasource=docker depName=docker.io/library/alpine
ARG alpine_version=3.24
# renovate: datasource=docker depName=docker.io/restic/restic
ARG restic_version=0.18.1
# renovate: datasource=docker depName=docker.io/library/docker
ARG docker_cli_version=29.8.1
# Stage 0a: Source the pinned restic binary
FROM docker.io/restic/restic:${restic_version} AS restic
# Stage 0b: Source the pinned Docker CLI binary (and the compose plugin)
FROM docker.io/library/docker:${docker_cli_version}-cli AS docker-cli
# Stage 1: Test image. Debian-based for CGO (required by -race detector).
# Runs as root: needs Docker socket + /var/lib/docker/volumes access.
FROM docker.io/library/golang:${go_version} AS test
# Copy restic + docker CLI + docker compose plugin from the pinned upstreams
COPY --from=restic --link /usr/bin/restic /usr/bin/restic
COPY --from=docker-cli --link /usr/local/bin/docker /usr/local/bin/docker
COPY --from=docker-cli --link /usr/local/libexec/docker/cli-plugins/ /usr/local/libexec/docker/cli-plugins/
# renovate: datasource=go depName=gotest.tools/gotestsum
ARG gotestsum_version=v1.13.0
RUN go install gotest.tools/gotestsum@${gotestsum_version} && \
gotestsum --version && \
docker --version && \
docker compose version
# Stage 2: Build the conba binary
FROM docker.io/library/golang:${go_version} AS builder
ARG app_version=edge
ARG build_commit_sha=unknown
ARG restic_version
WORKDIR /build
COPY --link go.mod go.sum ./
RUN go mod download && go mod verify
COPY --link . .
RUN CGO_ENABLED=0 go build -buildvcs=false \
-ldflags "-X github.com/lazybytez/conba/internal/build.Version=${app_version} -X github.com/lazybytez/conba/internal/build.CommitSHA=${build_commit_sha} -X github.com/lazybytez/conba/internal/build.ResticVersion=${restic_version}" \
-o /build/conba ./cmd/conba
# Stage 3: Minimal runtime image
# Runs as root: conba needs access to the Docker socket (root:docker 660)
# and /var/lib/docker/volumes (root-owned) to snapshot container volumes.
FROM docker.io/library/alpine:${alpine_version} AS base
RUN apk add --no-cache tini && \
rm -rf /var/cache/apk/* /tmp/*
WORKDIR /app
COPY --from=builder --link --chmod=755 /build/conba ./conba
COPY --from=restic --link --chmod=755 /usr/bin/restic /usr/local/bin/restic
LABEL org.opencontainers.image.title="conba"
LABEL org.opencontainers.image.description="A simple restic-based container volume backup tool"
LABEL org.opencontainers.image.vendor="Lazy Bytez"
LABEL org.opencontainers.image.source="https://github.com/lazybytez/conba"
LABEL org.opencontainers.image.licenses="MIT"
ENTRYPOINT ["/sbin/tini", "--", "/app/conba"]