File tree Expand file tree Collapse file tree 1 file changed +13
-30
lines changed
Expand file tree Collapse file tree 1 file changed +13
-30
lines changed Original file line number Diff line number Diff line change 1- # Build stage
2- FROM golang:1.22- alpine AS builder
1+ # Use a minimal base image for the final stage
2+ FROM alpine:latest AS base
33
4- # Install build dependencies
5- RUN apk add --no-cache git ca-certificates tzdata
4+ # Install ca-certificates for HTTPS requests
5+ RUN apk --no-cache add ca-certificates tzdata
66
7- # Set working directory
8- WORKDIR /app
9-
10- # Copy go module files first
11- COPY go.mod go.sum ./
12-
13- # Download dependencies
14- RUN go mod download
15-
16- # Copy source code
17- COPY . .
18-
19- # Build the application
20- RUN CGO_ENABLED=0 GOOS=linux go build \
21- -ldflags='-w -s -extldflags "-static"' \
22- -a -installsuffix cgo \
23- -o gh-notif \
24- ./main.go
7+ # Create a non-root user
8+ RUN adduser -D -s /bin/sh appuser
259
2610# Final stage
2711FROM scratch
2812
29- # Import from builder
30- COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
31- COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
13+ # Import from base
14+ COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
15+ COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo
3216
33- # Copy the binary
34- COPY --from=builder /app/ gh-notif /usr/local/bin/gh-notif
17+ # Copy the pre-built binary (provided by GoReleaser)
18+ COPY gh-notif /usr/local/bin/gh-notif
3519
3620# Copy documentation
37- COPY --from=builder /app/docs /docs
38- COPY --from=builder /app/README.md /README.md
39- COPY --from=builder /app/LICENSE /LICENSE
21+ COPY README.md /README.md
22+ COPY LICENSE /LICENSE
4023
4124# Set the entrypoint
4225ENTRYPOINT ["/usr/local/bin/gh-notif" ]
You can’t perform that action at this time.
0 commit comments