Skip to content
Merged
Show file tree
Hide file tree
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: 6 additions & 11 deletions deployments/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} go build \
-o schematic-datastream-replicator \
.

# Runtime stage using distroless for minimal attack surface
FROM gcr.io/distroless/static-debian12:nonroot
# Runtime stage using Alpine for minimal attack surface with built-in curl
FROM alpine:3.18

# Re-declare build args for runtime stage
ARG BUILDTIME
Expand All @@ -58,26 +58,21 @@ ARG REVISION
ARG HEALTH_PORT=8090
ENV HEALTH_PORT=${HEALTH_PORT}

# Copy CA certificates for HTTPS requests
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# Install curl and ca-certificates for health checks
RUN apk add --no-cache curl ca-certificates

# Copy the binary from builder stage
COPY --from=builder /app/schematic-datastream-replicator /app/schematic-datastream-replicator

# Use non-root user (distroless nonroot user has UID 65532)
USER 65532:65532
# Use non-root user (Alpine nobody user has UID 65534)
USER 65534:65534

# Set working directory
WORKDIR /app

# Expose health check port (configurable via HEALTH_PORT build arg)
EXPOSE ${HEALTH_PORT}

# No built-in health check - let orchestrators handle health checks via HTTP endpoints
# Health endpoints available at:
# - GET /health (liveness probe)
# - GET /ready (readiness probe)

# Set OCI labels for production readiness
LABEL \
org.opencontainers.image.title="Schematic Datastream Replicator" \
Expand Down
9 changes: 7 additions & 2 deletions deployments/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ services:
build:
context: ..
dockerfile: deployments/Dockerfile
platforms:
- linux/amd64
# platform: auto-detected based on your machine
args:
- HEALTH_PORT=${HEALTH_PORT:-8090}
image: schematic-replicator:latest
Expand All @@ -36,6 +35,12 @@ services:
- REDIS_ADDR=redis:6379
- REDIS_PASSWORD=${REDIS_PASSWORD:-}
- REDIS_DB=${REDIS_DB:-0}
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8090/health || exit 1"]
interval: 10s
timeout: 10s
retries: 3
start_period: 10s
depends_on:
redis:
condition: service_healthy
Expand Down