forked from anyproto/any-sync-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (32 loc) · 1.47 KB
/
Dockerfile
File metadata and controls
44 lines (32 loc) · 1.47 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
# Step 1: Build
FROM --platform=$BUILDPLATFORM golang:1.24-alpine AS builder
ARG TARGETOS=linux
ARG TARGETARCH
WORKDIR /src
RUN apk add --no-cache git ca-certificates
# Use Docker BuildKit cache for modules
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
COPY . .
# Build all three tools for the target arch
ENV CGO_ENABLED=0
RUN --mount=type=cache,target=/root/.cache/go-build \
GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /out/any-sync-network ./any-sync-network && \
GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /out/any-sync-netcheck ./any-sync-netcheck && \
GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /out/any-sync-acl-cli ./any-sync-acl-cli && \
GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /out/anyconf ./anyconf
# Step 2: Runtime
FROM alpine:3.22.1
# OCI labels
LABEL org.opencontainers.image.title="any-sync-tools" \
org.opencontainers.image.description="Configuration tools for Any-Sync network" \
org.opencontainers.image.source="https://github.com/anyproto/any-sync-tools" \
org.opencontainers.image.licenses="MIT"
WORKDIR /app
COPY --from=builder /out/any-sync-network /usr/local/bin/any-sync-network
COPY --from=builder /src/any-sync-network/defaultTemplate.yml .
COPY --from=builder /out/any-sync-netcheck /usr/local/bin/any-sync-netcheck
COPY --from=builder /out/anyconf /usr/local/bin/anyconf
COPY --from=builder /out/any-sync-acl-cli /usr/local/bin/any-sync-acl-cli
CMD ["any-sync-network", "--help"]