25 lines
681 B
Docker
25 lines
681 B
Docker
########################
|
|
# — Build stage —
|
|
########################
|
|
FROM golang:1.23.4-alpine AS builder
|
|
|
|
# git is needed to fetch modules and root CAs
|
|
RUN apk add --no-cache git ca-certificates
|
|
|
|
WORKDIR /src
|
|
|
|
# Bring in the source (vendor dir included)
|
|
COPY . .
|
|
|
|
# Build static binary using vendored dependencies
|
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -mod=vendor -o /out/action ./main.go
|
|
|
|
########################
|
|
# — Runtime stage —
|
|
########################
|
|
FROM alpine:3.20
|
|
RUN apk add --no-cache git ca-certificates openssh
|
|
ENV PATH="/usr/bin:/usr/sbin:/bin:/sbin"
|
|
COPY --from=builder /out/action /usr/local/bin/action
|
|
ENTRYPOINT ["/usr/local/bin/action"]
|