-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use go modules instead of dep. Use two stage build to build a minimal (4 MB) application image. Fixes #51 #71 #78
- Loading branch information
1 parent
8746277
commit e596161
Showing
2 changed files
with
18 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
FROM golang:1-alpine AS build-env | ||
FROM golang:1.16 AS build | ||
|
||
RUN apk add --no-cache --upgrade git openssh-client ca-certificates | ||
RUN go get -u github.com/golang/dep/cmd/dep | ||
WORKDIR /go/src/app | ||
WORKDIR /app | ||
|
||
# Install | ||
RUN go get -u github.com/google/addlicense | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
ENTRYPOINT ["addlicense"] | ||
# copy source and build | ||
COPY . . | ||
RUN CGO_ENABLED=0 GOOS=linux go build . | ||
|
||
|
||
# make a bare minimal image | ||
FROM scratch | ||
|
||
# source to be scanned should be mounted to /src | ||
WORKDIR /src | ||
COPY --from=build /app/addlicense /app/addlicense | ||
|
||
ENTRYPOINT ["/app/addlicense"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters