Skip to content

Commit

Permalink
Enhance Dockerfile adding multistage build (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergioasantiago authored Feb 6, 2023
1 parent 5a51292 commit a57a990
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ release:
dockers:
- image_templates:
- "ghcr.io/jetstack/dependency-track-exporter:{{.Version}}-amd64"
dockerfile: Dockerfile
dockerfile: Dockerfile.goreleaser
use: buildx
build_flag_templates:
- "--pull"
Expand All @@ -38,7 +38,7 @@ dockers:
- "--platform=linux/amd64"
- image_templates:
- "ghcr.io/jetstack/dependency-track-exporter:{{.Version}}-arm64"
dockerfile: Dockerfile
dockerfile: Dockerfile.goreleaser
use: buildx
build_flag_templates:
- "--pull"
Expand Down
27 changes: 24 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
FROM golang:1.19-buster AS build

WORKDIR /app

COPY go.mod ./

COPY go.sum ./

RUN go mod download

COPY *.go ./

COPY internal ./internal

RUN go build -o /dependency-track-exporter

FROM gcr.io/distroless/static:nonroot

COPY dependency-track-exporter /
WORKDIR /

COPY --from=build /dependency-track-exporter /dependency-track-exporter

EXPOSE 9916

USER nonroot:nonroot

USER nonroot
ENTRYPOINT ["/dependency-track-exporter"]
ENTRYPOINT ["/dependency-track-exporter"]
7 changes: 7 additions & 0 deletions Dockerfile.goreleaser
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM gcr.io/distroless/static:nonroot

COPY dependency-track-exporter /

USER nonroot

ENTRYPOINT ["/dependency-track-exporter"]

0 comments on commit a57a990

Please sign in to comment.