43 lines
859 B
Docker
43 lines
859 B
Docker
# 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"]
|
|
|