forked from chrxmvtik/gitlab-mr-conform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
38 lines (27 loc) · 901 Bytes
/
Dockerfile
File metadata and controls
38 lines (27 loc) · 901 Bytes
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
# Multi-stage build for Go bot application
# Supports both AMD64 and ARM64 architectures
FROM --platform=$BUILDPLATFORM golang:1.24.4-alpine AS build
# Set working directory
WORKDIR /app
# Copy go mod files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy source code
COPY . .
# Build arguments for cross-compilation
ARG TARGETOS=linux
ARG TARGETARCH
# Build the application
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build \
-ldflags='-w -s' \
-o bot ./cmd/bot
# Final stage - minimal distroless image
FROM --platform=$TARGETPLATFORM gcr.io/distroless/static-debian12:nonroot
# Copy binary and configs from build stage
COPY --from=build --chown=nonroot:nonroot /app/bot /
COPY --from=build --chown=nonroot:nonroot /app/configs ./configs
# Use nonroot user (already defined in distroless image)
USER nonroot
# Run the bot application
CMD ["/bot"]