Build and Push Docker Image / build-and-push (push) Successful in 3m10s
Signed-off-by: kaedwen <kaedwen@heinrich.blue>
61 lines
1.4 KiB
Docker
61 lines
1.4 KiB
Docker
# Debug build with shell and tools
|
|
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
|
|
|
|
# Debug runtime stage - Alpine with shell and debugging tools
|
|
FROM alpine:latest
|
|
|
|
# Install debugging tools
|
|
RUN apk add --no-cache \
|
|
bash \
|
|
curl \
|
|
wget \
|
|
netcat-openbsd \
|
|
bind-tools \
|
|
busybox-extras \
|
|
ca-certificates \
|
|
sqlite \
|
|
tzdata
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy binary from builder (migrations are embedded in binary)
|
|
COPY --from=builder /build/aitrade /app/aitrade
|
|
COPY --from=builder /build/healthcheck /app/healthcheck
|
|
|
|
# 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 nonroot
|
|
|
|
# Expose web port
|
|
EXPOSE 8080
|
|
|
|
# Health check using custom binary
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD ["/app/healthcheck", "localhost", "8080"]
|
|
|
|
# Run application
|
|
ENTRYPOINT ["/app/aitrade"]
|