Files
bamort/docker/Dockerfile.backend
T

32 lines
591 B
Docker
Raw Normal View History

2025-08-14 23:25:01 +02:00
# =========== 1) Build stage ===========
FROM golang:1.24-alpine AS builder
# Install necessary packages for CGO and SQLite
RUN apk add --no-cache gcc musl-dev sqlite-dev
WORKDIR /app
# Copy go.mod and go.sum first
COPY go.mod go.sum ./
RUN go mod download
# Copy the rest of the backend code
COPY . .
# Build the Go binary
RUN go build -v -o server cmd/main.go
# =========== 2) Runtime stage ===========
FROM alpine:3.18
WORKDIR /app
# Copy the compiled binary from builder stage
COPY --from=builder /app/server /app
# Expose port
EXPOSE 8180
# Run the Go server
CMD ["./server"]