40 lines
692 B
Docker
Raw Permalink Normal View History

2025-05-05 23:30:38 +00:00
# Build stage
FROM golang:1.24-alpine AS builder
WORKDIR /app
# Install build dependencies
RUN apk add --no-cache gcc musl-dev
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build the application
RUN CGO_ENABLED=1 GOOS=linux go build -o server ./cmd/server
# Final stage
FROM alpine:latest
WORKDIR /app
# Install runtime dependencies
RUN apk add --no-cache sqlite
# Copy the binary from builder
COPY --from=builder /app/server .
# Create directory for database
RUN mkdir -p /data
2025-05-07 00:25:34 +03:00
COPY /internal/db/data.db /data/data.db
2025-05-05 23:30:38 +00:00
# Expose the port
EXPOSE 8080
# Run the application
CMD ["./server", "--db", "/data/data.db", "--listen", "8080"]