atri.dad/Dockerfile
Atridad Lahiji 97b805b422
Some checks failed
Docker Deploy / build-and-push (push) Failing after 46s
Fixed docker issues
2025-02-01 17:12:52 -06:00

32 lines
680 B
Docker

FROM golang:1.23.2-alpine AS builder
WORKDIR /app
# Download dependencies and install required tools
COPY go.mod go.sum ./
RUN go mod download && \
go install github.com/swaggo/swag/cmd/swag@latest
# Copy source code
COPY . .
# Install tools
RUN apk add --no-cache upx make
# Generate assets and build with optimizations
RUN set -eux; \
cd /app; \
make generate; \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags='-s -w -extldflags "-static"' \
-tags netgo,osusergo \
-o /go/bin/app
# Final stage
FROM scratch
# Copy static files and assets
COPY --from=builder /app/docs /docs
COPY --from=builder /go/bin/app /app
ENTRYPOINT ["/app"]