sync to distroless
Build and Push Docker Image / build-and-push (push) Successful in 3m10s

Signed-off-by: kaedwen <kaedwen@heinrich.blue>
This commit is contained in:
kaedwen
2026-07-04 21:04:13 +02:00
parent 0a52786c86
commit ee77ea0aaf
2 changed files with 10 additions and 22 deletions
-5
View File
@@ -3,11 +3,6 @@ FROM golang:1.26-alpine AS builder
WORKDIR /build WORKDIR /build
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . . COPY . .
# Build the application (static binary, no CGO, migrations embedded) # Build the application (static binary, no CGO, migrations embedded)
+10 -17
View File
@@ -3,27 +3,19 @@ FROM golang:1.26-alpine AS builder
WORKDIR /build WORKDIR /build
# Install build dependencies
RUN apk add --no-cache git
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . . COPY . .
# Build the application (static binary, no CGO, migrations embedded) # Build the application (static binary, no CGO, migrations embedded)
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-a \ -trimpath \
-installsuffix cgo \ -ldflags="-w -s" \
-ldflags="-w -s -extldflags '-static'" \
-o aitrade \ -o aitrade \
./cmd/aitrade ./cmd/aitrade
# Build healthcheck utility # Build healthcheck utility
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags="-w -s -extldflags '-static'" \ -trimpath \
-ldflags="-w -s" \
-o healthcheck \ -o healthcheck \
./cmd/healthcheck ./cmd/healthcheck
@@ -49,12 +41,13 @@ WORKDIR /app
COPY --from=builder /build/aitrade /app/aitrade COPY --from=builder /build/aitrade /app/aitrade
COPY --from=builder /build/healthcheck /app/healthcheck COPY --from=builder /build/healthcheck /app/healthcheck
# Create non-root user # Create non-root user with same UID as distroless (65532)
RUN addgroup -g 1000 appuser && \ RUN addgroup -g 65532 nonroot && \
adduser -D -u 1000 -G appuser appuser && \ adduser -D -u 65532 -G nonroot nonroot && \
chown -R appuser:appuser /app mkdir -p /app/data && \
chown -R nonroot:nonroot /app
USER appuser USER nonroot
# Expose web port # Expose web port
EXPOSE 8080 EXPOSE 8080