-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (34 loc) · 1.62 KB
/
Dockerfile
File metadata and controls
44 lines (34 loc) · 1.62 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
# Development Dockerfile for basecamp
#
# NOTE: This Dockerfile requires vendored dependencies or BuildKit secrets
# for the private basecamp-sdk. For local builds, either:
# 1. Run `go mod vendor` first, then build with: docker build .
# 2. Use GoReleaser for release builds (handles auth automatically)
#
# For CI/release builds, use Dockerfile.goreleaser instead.
FROM golang:1.26-alpine AS builder
RUN apk add --no-cache git ca-certificates
WORKDIR /app
COPY go.mod go.sum ./
COPY . .
ARG VERSION=dev
ARG COMMIT=unknown
ARG BUILD_DATE=unknown
# Build with vendored deps if available, otherwise try to download (may fail without auth for private SDK)
RUN if [ -d vendor ]; then \
CGO_ENABLED=0 GOOS=linux go build -mod=vendor \
-trimpath \
-ldflags="-s -w -X github.com/basecamp/basecamp-cli/internal/version.Version=${VERSION} -X github.com/basecamp/basecamp-cli/internal/version.Commit=${COMMIT} -X github.com/basecamp/basecamp-cli/internal/version.Date=${BUILD_DATE}" \
-o /basecamp ./cmd/basecamp; \
else \
go mod download && \
CGO_ENABLED=0 GOOS=linux go build \
-trimpath \
-ldflags="-s -w -X github.com/basecamp/basecamp-cli/internal/version.Version=${VERSION} -X github.com/basecamp/basecamp-cli/internal/version.Commit=${COMMIT} -X github.com/basecamp/basecamp-cli/internal/version.Date=${BUILD_DATE}" \
-o /basecamp ./cmd/basecamp; \
fi
# Runtime stage using distroless for minimal attack surface
FROM gcr.io/distroless/static-debian12:nonroot
COPY --from=builder /basecamp /basecamp
USER nonroot:nonroot
ENTRYPOINT ["/basecamp"]