Dockerfile 857 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Build stage
  2. FROM golang:1.22.5-alpine AS builder
  3. # Install build dependencies
  4. RUN apk add --no-cache git make gcc musl-dev sqlite-dev
  5. WORKDIR /app
  6. # Copy go mod files
  7. COPY go.mod go.sum ./
  8. RUN go mod download
  9. # Copy source code
  10. COPY . .
  11. # Build the application
  12. RUN CGO_ENABLED=1 GOOS=linux go build -o byom-onboard ./cmd/api/main.go
  13. # Final stage
  14. FROM alpine:3.19
  15. # Install runtime dependencies
  16. RUN apk add --no-cache ca-certificates tzdata sqlite sqlite-dev
  17. # Create non-root user
  18. RUN adduser -D -H -h /app appuser
  19. WORKDIR /app
  20. # Copy binary from builder
  21. COPY --from=builder /app/byom-onboard .
  22. COPY config.yaml .
  23. # Create data directory and set permissions
  24. RUN mkdir -p /app/data && \
  25. chown -R appuser:appuser /app
  26. USER appuser
  27. EXPOSE 8080
  28. ENV CONFIG_FILE=/app/config.yaml
  29. CMD ["./byom-onboard", "serve", "--config=/app/config.yaml"]