Files
WPSidekick/Dockerfile
T
2026-01-25 08:57:55 +01:00

48 lines
1.0 KiB
Docker

# Multi-stage build for optimized image size
# Stage 1: Builder
FROM golang:1.21-alpine AS builder
WORKDIR /build
# Install build dependencies
RUN apk add --no-cache git
# Copy dependency files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build binary with optimizations
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o seo-optimizer ./cmd/optimizer
# Stage 2: Final image
FROM alpine:latest
# Install ca-certificates for HTTPS and tzdata for timezone support
RUN apk --no-cache add ca-certificates tzdata
WORKDIR /app
# Copy binary from builder
COPY --from=builder /build/seo-optimizer .
COPY --from=builder /build/configs/config.example.yaml ./configs/
# Create non-root user
RUN adduser -D -u 1000 appuser && \
chown -R appuser:appuser /app
USER appuser
# Expose API port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD wget --quiet --tries=1 --spider http://localhost:8080/api/v1/health || exit 1
# Run application
ENTRYPOINT ["./seo-optimizer"]