# Dockerfile FROM golang:1.24-alpine AS builder WORKDIR /app # Copy go.mod and go.sum files COPY go.mod go.sum ./ # Download dependencies RUN go mod download # Copy the source code COPY . . # Build the application RUN CGO_ENABLED=0 GOOS=linux go build -o url-shortener . # Use a smaller image for the final build FROM alpine:latest WORKDIR /app # Copy the binary from the builder stage COPY --from=builder /app/url-shortener . # Copy templates and static files COPY --from=builder /app/templates ./templates COPY --from=builder /app/static ./static # Expose the port EXPOSE 8080 # Run the binary CMD ["./url-shortener"]