Closed xueshanf closed 6 years ago
This is the appropriate to make Docker containers. Nice job @xueshanf
@hashmap this should be okay to merge... it would make docker build simpler. Let me know if you need more help.
Nice @xueshanf! Would be nice to have this merged, seems to be working as expected:
git clone https://github.com/optiopay/klar.git
cd klar
vim Dockerfile
# Applying patch
docker build --rm -t klar:latest .
Sending build context to Docker daemon 9.623MB
Step 1/8 : FROM golang:1.8-alpine as builder
1.8-alpine: Pulling from library/golang
128191993b8a: Pull complete
4142fc54ba37: Pull complete
f89b95e5f550: Pull complete
df65b313bcae: Pull complete
2cf5b3b9ca06: Pull complete
73411f5d3307: Pull complete
Digest: sha256:4d8a2804b49a4c2208b811cf402d505a8cc55419785976fa90f2b63198026d5e
Status: Downloaded newer image for golang:1.8-alpine
---> 340ce9f2f12e
Step 2/8 : RUN apk --update add git;
---> Running in 76a9a5989ab0
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz
(1/5) Installing libssh2 (1.7.0-r2)
(2/5) Installing libcurl (7.57.0-r0)
(3/5) Installing expat (2.2.0-r1)
(4/5) Installing pcre (8.39-r0)
(5/5) Installing git (2.11.3-r0)
Executing busybox-1.25.1-r1.trigger
OK: 24 MiB in 17 packages
Removing intermediate container 76a9a5989ab0
---> afff502e82ac
Step 3/8 : RUN go get -d github.com/optiopay/klar
---> Running in 909037b746b5
Removing intermediate container 909037b746b5
---> ea98e4961696
Step 4/8 : RUN go build ./src/github.com/optiopay/klar
---> Running in ec1d3dc796ee
Removing intermediate container ec1d3dc796ee
---> 8060a37fc01a
Step 5/8 : FROM alpine:3.6
3.6: Pulling from library/alpine
1160f4abea84: Already exists
Digest: sha256:42c18571af45ffc440bd5127de9ad604f1683e4799dbf7bf588aaee8f95c18f1
Status: Downloaded newer image for alpine:3.6
---> e2cd449cde75
Step 6/8 : RUN apk add --no-cache ca-certificates
---> Running in 6ebaf44da1f1
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz
(1/1) Installing ca-certificates (20161130-r2)
Executing busybox-1.26.2-r9.trigger
Executing ca-certificates-20161130-r2.trigger
OK: 5 MiB in 12 packages
Removing intermediate container 6ebaf44da1f1
---> a72674e9f85a
Step 7/8 : COPY --from=builder /go/klar /klar
---> 2a361b0396c3
Step 8/8 : ENTRYPOINT ["/klar"]
---> Running in b6cd8b60c197
Removing intermediate container b6cd8b60c197
---> fb727170c1d0
Successfully built fb727170c1d0
Successfully tagged klar:latest
docker run -e CLAIR_ADDR="http://localhost:6060" \
-e CLAIR_OUTPUT=Unknown \
-e CLAIR_THRESHOLD=10 \
klar centos:7
Analysing 1 layers
Got results from Clair API v1
Found 0 vulnerabilities
This was done with docker version 17.12.0-ce
I realized that the build won't work until docker 17.05. It works on my Mac (17.06), but doesn't work with Docker Hub (17.03). Better to ignore this PR until everyone catch up the new release, I think.