better-argo-tunnels/Dockerfile

40 lines
809 B
Docker

# syntax=docker/dockerfile:1
FROM golang:1.24-alpine AS builder
RUN apk add --no-cache git
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# Build both binaries as static.
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /tunnel-server ./cmd/server/
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /tunnel-client ./cmd/client/
# --- Server image ---
FROM alpine:3.21 AS server
RUN apk add --no-cache ca-certificates
COPY --from=builder /tunnel-server /usr/local/bin/tunnel-server
RUN mkdir -p /keys /etc/traefik/dynamic
EXPOSE 2222
EXPOSE 10000-10100
ENTRYPOINT ["tunnel-server"]
# --- Client image ---
FROM alpine:3.21 AS client
RUN apk add --no-cache ca-certificates
COPY --from=builder /tunnel-client /usr/local/bin/tunnel-client
RUN mkdir -p /keys
ENTRYPOINT ["tunnel-client"]