Template
1
0
Fork 0
goth.stack/Dockerfile

27 lines
448 B
Text
Raw Normal View History

2024-11-03 16:06:21 -06:00
FROM golang:1.23.2-alpine AS builder
2024-05-14 00:00:28 -06:00
WORKDIR /app
2024-11-03 16:06:21 -06:00
# Download dependencies
2024-10-21 21:20:39 -06:00
COPY go.mod go.sum ./
2024-05-14 00:00:28 -06:00
RUN go mod download
2024-10-21 21:20:39 -06:00
2024-11-03 16:06:21 -06:00
# Copy source code
2024-10-21 21:20:39 -06:00
COPY . .
2024-11-03 16:06:21 -06:00
# Install UPX
RUN apk add --no-cache upx
# Build with optimizations
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags='-s -w -extldflags "-static"' \
-tags netgo,osusergo \
-o /go/bin/app
2024-05-14 00:00:28 -06:00
2024-11-03 16:06:21 -06:00
# Final stage
2024-08-09 09:46:54 -06:00
FROM scratch
2024-05-14 00:00:28 -06:00
2024-11-03 16:06:21 -06:00
COPY --from=builder /go/bin/app /app
2024-05-14 00:00:28 -06:00
2024-10-21 21:20:39 -06:00
ENTRYPOINT ["/app"]