Files
kontor/kontor-echo/Dockerfile
2026-01-03 04:07:42 +01:00

29 lines
938 B
Docker

# ---------- Stage 1: Build ----------
FROM golang:1.25-alpine AS builder
# Set the working directory
WORKDIR /app
# Ensure a portable, static-ish binary
ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64
# Copy and download dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy the source code
COPY . .
# Build the Go application (strip debug info for smaller size)
RUN go build -trimpath -ldflags="-s -w" -o kontor cmd/kontor/main.go
# ---------- Stage 2: Final ----------
FROM alpine:latest
# Set the working directory
WORKDIR /app
# Install runtime dependencies you actually need
RUN apk add --no-cache ca-certificates tzdata curl
# Create non-root user for security
RUN addgroup -S kontor && adduser -S -G kontor -H -s /sbin/nologin kontor
# Copy the binary and set ownership
COPY --from=builder --chown=kontor:kontor /app/kontor /app/kontor
# Run as non-root user
USER kontor
# Set the entrypoint command
ENTRYPOINT ["/app/kontor"]