Skip to content

Commit ef04bb3

Browse files
authored
Merge pull request #82 from willnorris/docker
fix building docker image
2 parents 0f8d403 + e596161 commit ef04bb3

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

Dockerfile

+17-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
FROM golang:1-alpine AS build-env
1+
FROM golang:1.16 AS build
22

3-
RUN apk add --no-cache --upgrade git openssh-client ca-certificates
4-
RUN go get -u github.com/golang/dep/cmd/dep
5-
WORKDIR /go/src/app
3+
WORKDIR /app
64

7-
# Install
8-
RUN go get -u github.com/google/addlicense
5+
COPY go.mod go.sum ./
6+
RUN go mod download
97

10-
ENTRYPOINT ["addlicense"]
8+
# copy source and build
9+
COPY . .
10+
RUN CGO_ENABLED=0 GOOS=linux go build .
11+
12+
13+
# make a bare minimal image
14+
FROM scratch
15+
16+
# source to be scanned should be mounted to /src
17+
WORKDIR /src
18+
COPY --from=build /app/addlicense /app/addlicense
19+
20+
ENTRYPOINT ["/app/addlicense"]

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ docker run -it google/addlicense -h
3838

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

4444
## license

0 commit comments

Comments
 (0)