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

fix building docker image #82

Merged
merged 1 commit into from
Jul 29, 2021
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
24 changes: 17 additions & 7 deletions Dockerfile
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why hardcoded vs. alpine or latest? not critizicing, just curious.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I typically lock in versions where I can. That gives me a chance to test things locally before committing to an upgrade. In this case, go only updates twice a year, so it's not much work to occasionally bump the build version. But of course, it is also probably unnecessarily conservative given the go1 compatibility promise. I don't have strong feelings on it, and am happy to go either way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's fine with me as is, I just wanted to understand the thinking, thanks!


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"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ docker run -it google/addlicense -h

- Usage example
```bash
docker run -v ${PWD}:/go/src/app/ -it google/addlicense -c "Google LLC" *.go
docker run -v ${PWD}:/src -it google/addlicense -c "Google LLC" *.go
```

## license
Expand Down