Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Dockerfile adding multistage build #47

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Enhance Dockerfile adding multistage build
  • Loading branch information
sergioasantiago committed Feb 2, 2023
commit 24f8da7ea0a526176ddc7bb8de761ac7a732a4ed
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"]