Skip to content

Commit

Permalink
fix: permission denied for /.cache/go-build in container
Browse files Browse the repository at this point in the history
caused by golang/go#26280 (comment)

relates to #230

Signed-off-by: nscuro <nscuro@protonmail.com>
  • Loading branch information
nscuro committed Aug 3, 2023
1 parent c44a3b1 commit 8e8abae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ COPY . .
RUN make install

FROM golang:1.20.4-alpine3.16@sha256:6469405d7297f82d56195c90a3270b0806ef4bd897aa0628477d9959ab97a577
# When running as non-root user, GOCACHE must be set to a directory
# that is writable by that user. It will otherwise default to /.cache/go-build,
# which is owned by root.
# https://github.com/golang/go/issues/26280#issuecomment-445294378
ENV GOCACHE=/tmp/go-build
COPY --from=build /go/bin/cyclonedx-gomod /usr/local/bin/
USER 1000
ENTRYPOINT ["cyclonedx-gomod"]
Expand Down
5 changes: 5 additions & 0 deletions Dockerfile.goreleaser
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# This Dockerfile is meant for GoReleaser exclusively, see .goreleaser.yml.
# For manual builds, please use the regular Dockerfile or simply run "make docker".
FROM golang:1.20.4-alpine3.16@sha256:6469405d7297f82d56195c90a3270b0806ef4bd897aa0628477d9959ab97a577
# When running as non-root user, GOCACHE must be set to a directory
# that is writable by that user. It will otherwise default to /.cache/go-build,
# which is owned by root.
# https://github.com/golang/go/issues/26280#issuecomment-445294378
ENV GOCACHE=/tmp/go-build
COPY cyclonedx-gomod /usr/local/bin/
USER 1000
ENTRYPOINT ["cyclonedx-gomod"]
Expand Down

0 comments on commit 8e8abae

Please sign in to comment.