feat: add Docker build

This commit is contained in:
2025-10-27 15:18:55 +01:00
parent 6ed905b9f3
commit 0c1434a9da
6 changed files with 73 additions and 5 deletions

42
Dockerfile Normal file
View File

@@ -0,0 +1,42 @@
# Build stage
FROM golang:1.22-alpine AS builder
WORKDIR /app
# Install build dependencies for CGO
RUN apk add --no-cache gcc musl-dev sqlite-dev
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build the application
# Note: CGO_ENABLED=1 is required for sqlite3
RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o spore-registry ./main.go
# Runtime stage
FROM alpine:latest
# Install ca-certificates, sqlite runtime, and wget for health checks
RUN apk --no-cache add ca-certificates sqlite wget
WORKDIR /root/
# Copy the binary from builder
COPY --from=builder /app/spore-registry .
# Create registry directory
RUN mkdir -p /data/registry
# Expose port
EXPOSE 8080
# Set environment variable for registry path
ENV REGISTRY_PATH=/data/registry
# Run the application
CMD ["./spore-registry"]