Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions components/public-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Build stage
FROM golang:1.24-alpine AS builder
FROM registry.access.redhat.com/ubi9/go-toolset:1.24 AS builder

WORKDIR /app

# Install git for fetching dependencies
RUN apk add --no-cache git
USER 0

# Copy go mod files first for caching
COPY go.mod go.sum* ./
Expand All @@ -17,26 +16,24 @@ COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o public-api .

# Runtime stage
FROM alpine:3.19

# Add ca-certificates for HTTPS requests
RUN apk --no-cache add ca-certificates
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.7

WORKDIR /app

# Copy binary from builder
COPY --from=builder /app/public-api .

# Create non-root user
RUN adduser -D -u 1001 appuser
# Set executable permissions
RUN chmod +x ./public-api && chmod 775 /app

USER 1001

# Expose port
EXPOSE 8081

# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8081/health || exit 1
CMD curl -sf http://localhost:8081/health || exit 1

# Run the binary
ENTRYPOINT ["./public-api"]
Loading