Skip to content

Commit

Permalink
feat(docker): move to a scratch image (~8mb)
Browse files Browse the repository at this point in the history
Move to using a 'scratch' Docker image, which allows us to execute
Kani directly without including an operating system in the image.
This significantly reduces the size of the output image.
  • Loading branch information
joshuasing committed Nov 24, 2022
1 parent 5c311e7 commit 3766d55
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
# syntax=docker/dockerfile:1

# Build stage
## Build stage
FROM golang:1.19.3-alpine as build

WORKDIR /build/kani
COPY . .

RUN GOOS=$(go env GOOS) GOARCH=$(go env GOARCH) go build ./cmd/kani
RUN GOOS=$(go env GOOS) GOARCH=$(go env GOARCH) CGO_ENABLED=0 GOGC=off \
go build -ldflags "-s -w" -o dist/kani ./cmd/kani

# Run stage
FROM golang:1.19.3-alpine
## Run stage
FROM scratch

RUN adduser -D kani
USER kani
COPY --from=build /build/kani/dist/kani /bin/kani

WORKDIR /home/kani
COPY --from=build --chown=kani:kani /build/kani/kani ./

CMD ["./kani"]
ENTRYPOINT ["/bin/kani"]

0 comments on commit 3766d55

Please sign in to comment.