Prepare for deployment

This commit is contained in:
2025-01-03 10:25:04 +01:00
parent d26f3dd3bf
commit 726c83dbbb
4 changed files with 45 additions and 5 deletions
+40
View File
@@ -0,0 +1,40 @@
# Build stage
FROM golang:1.22-alpine AS builder
WORKDIR /app
# Copy and download dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy the source code
COPY . .
# Install required packages for cgo
RUN apk add --no-cache gcc musl-dev
# Build with cgo enabled
ENV CGO_ENABLED=1
# Build the Go application
RUN go build -o app .
# Runtime stage
FROM alpine:latest
WORKDIR /root/
# Install SQLite CLI for runtime
RUN apk add --no-cache sqlite
# Copy the binary from the builder stage
COPY --from=builder /app/app .
COPY --from=builder /app/static/index.html.tmpl ./static/index.html.tmpl
COPY --from=builder /app/static/result.html.tmpl ./static/result.html.tmpl
# Expose the port the app runs on
EXPOSE 8080
# Run the application
CMD ["./app"]