Dockerfile 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. FROM golang:1.24.2-alpine AS builder
  2. WORKDIR /app
  3. # Install necessary build tools and SQLite dependencies
  4. RUN apk add --no-cache git make build-base sqlite-dev
  5. # Copy go mod files first for better caching
  6. COPY go.mod go.sum ./
  7. # Download dependencies
  8. RUN go mod download
  9. # Copy the rest of the source code
  10. COPY . .
  11. # Build the application with SQLite support
  12. RUN go build -tags 'sqlite' -o byop-engine .
  13. # Create a minimal production image
  14. FROM alpine:3.17
  15. WORKDIR /app
  16. # Install runtime dependencies including SQLite
  17. RUN apk add --no-cache ca-certificates tzdata sqlite
  18. # Create data directory for SQLite
  19. RUN mkdir -p /app/data && chmod 755 /app/data
  20. # Copy the binary from the builder stage
  21. COPY --from=builder /app/byop-engine /app/byop-engine
  22. COPY --from=builder /app/config.sample.yml /app/config.yaml
  23. # Create a non-root user and switch to it
  24. RUN adduser -D -u 1000 byopuser && \
  25. chown -R byopuser:byopuser /app
  26. USER byopuser
  27. # Expose the application port
  28. EXPOSE 8080
  29. # Run the application
  30. CMD ["/app/byop-engine"]