Skip to content

Commit

Permalink
fix: statically compile when doing direct docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
ekristen committed Apr 17, 2024
1 parent a2705c3 commit 0ffae13
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ RUN adduser -D aws-nuke
FROM ghcr.io/acorn-io/images-mirror/golang:1.21 AS build
COPY / /src
WORKDIR /src
ENV CGO_ENABLED=0
RUN \
--mount=type=cache,target=/go/pkg \
--mount=type=cache,target=/root/.cache/go-build \
go build -o bin/aws-nuke main.go
go build -ldflags '-s -w -extldflags="-static"' -o bin/aws-nuke main.go

FROM base AS goreleaser
FROM base AS gorelease
ENTRYPOINT ["/usr/local/bin/aws-nuke"]
COPY aws-nuke /usr/local/bin/aws-nuke
USER aws-nuke

FROM base
ENTRYPOINT ["/usr/local/bin/aws-nuke"]
COPY --from=build /src/bin/aws-nuke /usr/local/bin/aws-nuke
COPY --from=build --chmod=755 /src/bin/aws-nuke /usr/local/bin/aws-nuke
RUN chmod +x /usr/local/bin/aws-nuke
USER aws-nuke

0 comments on commit 0ffae13

Please sign in to comment.