first commit
This commit is contained in:
43
Dockerfile
Normal file
43
Dockerfile
Normal file
@@ -0,0 +1,43 @@
|
||||
# Build Stage
|
||||
FROM golang:1.25.6-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install build dependencies including libwebp
|
||||
RUN apk add --no-cache git gcc musl-dev libwebp-dev
|
||||
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
COPY . .
|
||||
|
||||
# Fix missing entries in go.sum (run after COPY to fix overwritten files)
|
||||
RUN go mod tidy
|
||||
RUN k=$(ls -la) && echo "$k"
|
||||
|
||||
# Install swag
|
||||
RUN go install github.com/swaggo/swag/cmd/swag@latest
|
||||
|
||||
# Generate swagger docs
|
||||
RUN swag init
|
||||
|
||||
# Build the binary with CGO enabled for WebP support
|
||||
RUN CGO_ENABLED=1 GOOS=linux go build -a -ldflags '-linkmode external -extldflags "-static"' -o main .
|
||||
|
||||
# Run Stage
|
||||
FROM alpine:latest
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install runtime dependencies: CA certificates and libwebp
|
||||
RUN apk --no-cache add ca-certificates libwebp
|
||||
|
||||
COPY --from=builder /app/main .
|
||||
COPY --from=builder /app/.env .
|
||||
COPY --from=builder /app/web ./web
|
||||
COPY --from=builder /app/docs ./docs
|
||||
# Note: .env might be overridden by docker-compose environment
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["./main"]
|
||||
Reference in New Issue
Block a user