From ee77ea0aafa4e50b91b07942ff1b84a2267c21c9 Mon Sep 17 00:00:00 2001 From: kaedwen Date: Sat, 4 Jul 2026 21:04:13 +0200 Subject: [PATCH] sync to distroless Signed-off-by: kaedwen --- Dockerfile | 5 ----- Dockerfile.debug | 27 ++++++++++----------------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index e78a591..5342b61 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,11 +3,6 @@ FROM golang:1.26-alpine AS builder WORKDIR /build -# Copy go mod files -COPY go.mod go.sum ./ -RUN go mod download - -# Copy source code COPY . . # Build the application (static binary, no CGO, migrations embedded) diff --git a/Dockerfile.debug b/Dockerfile.debug index 71d3fe5..5f1022d 100644 --- a/Dockerfile.debug +++ b/Dockerfile.debug @@ -3,27 +3,19 @@ FROM golang:1.26-alpine AS builder 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 . . # Build the application (static binary, no CGO, migrations embedded) RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \ - -a \ - -installsuffix cgo \ - -ldflags="-w -s -extldflags '-static'" \ + -trimpath \ + -ldflags="-w -s" \ -o aitrade \ ./cmd/aitrade # Build healthcheck utility RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \ - -ldflags="-w -s -extldflags '-static'" \ + -trimpath \ + -ldflags="-w -s" \ -o healthcheck \ ./cmd/healthcheck @@ -49,12 +41,13 @@ WORKDIR /app COPY --from=builder /build/aitrade /app/aitrade COPY --from=builder /build/healthcheck /app/healthcheck -# Create non-root user -RUN addgroup -g 1000 appuser && \ - adduser -D -u 1000 -G appuser appuser && \ - chown -R appuser:appuser /app +# Create non-root user with same UID as distroless (65532) +RUN addgroup -g 65532 nonroot && \ + adduser -D -u 65532 -G nonroot nonroot && \ + mkdir -p /app/data && \ + chown -R nonroot:nonroot /app -USER appuser +USER nonroot # Expose web port EXPOSE 8080