Files
kaedwen ee77ea0aaf
Build and Push Docker Image / build-and-push (push) Successful in 3m10s
sync to distroless
Signed-off-by: kaedwen <kaedwen@heinrich.blue>
2026-07-04 21:04:13 +02:00

47 lines
1.3 KiB
Docker

# Multi-stage build for AI Trading Application (Pure Go, no CGO)
FROM golang:1.26-alpine AS builder
WORKDIR /build
COPY . .
# Build the application (static binary, no CGO, migrations embedded)
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-trimpath \
-ldflags="-w -s" \
-o aitrade \
./cmd/aitrade
# Build healthcheck utility
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-trimpath \
-ldflags="-w -s" \
-o healthcheck \
./cmd/healthcheck
# Runtime stage - Google Distroless (minimal, secure, with CA certs and tzdata)
FROM gcr.io/distroless/static-debian12:nonroot
# Set working directory
WORKDIR /app
# Copy binary from builder (migrations are embedded in binary)
COPY --from=builder /build/aitrade /app/aitrade
# Copy healthcheck utility
COPY --from=builder /build/healthcheck /app/healthcheck
# Note: Distroless runs as nonroot user (UID 65532) by default
# Data directory needs to be mounted with correct permissions:
# mkdir -p data && chown 65532:65532 data
# Expose web port
EXPOSE 8080
# Health check using custom binary (lightweight, no curl/wget needed)
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD ["/app/healthcheck", "localhost", "8080"]
# Run application
ENTRYPOINT ["/app/aitrade"]