-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.arm
More file actions
51 lines (38 loc) · 1.28 KB
/
Dockerfile.arm
File metadata and controls
51 lines (38 loc) · 1.28 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
# Multi-stage Docker build for ARM
FROM --platform=$BUILDPLATFORM golang:1.21-alpine AS builder
# Install build dependencies for cross-compilation
RUN apk add --no-cache git ca-certificates gcc musl-dev
# Build arguments
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
WORKDIR /app
# Copy go modules
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build both binaries for target platform
RUN CGO_ENABLED=1 GOOS=$TARGETOS GOARCH=$TARGETARCH \
go build -a -ldflags='-w -s -extldflags "-static"' \
-o crucible .
# Check if monitor command exists, if not copy main binary
RUN if [ -d "./cmd/crucible-monitor" ]; then \
CGO_ENABLED=1 GOOS=$TARGETOS GOARCH=$TARGETARCH \
go build -a -ldflags='-w -s -extldflags "-static"' \
-o crucible-monitor ./cmd/crucible-monitor; \
else \
cp crucible crucible-monitor; \
fi
# Final stage - minimal runtime
FROM scratch
# Copy CA certificates for HTTPS
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# Copy binaries
COPY --from=builder /app/crucible /crucible
COPY --from=builder /app/crucible-monitor /crucible-monitor
# Copy config files
COPY --from=builder /app/configs /configs
EXPOSE 9090
# Default to monitor, but can be overridden
ENTRYPOINT ["/crucible-monitor"]