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
# 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)
+10 -17
View File
@@ -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