Skip to content

Commit

Permalink
Merge pull request #6 from PercussiveElbow/scratch_container
Browse files Browse the repository at this point in the history
Scratch image base and drop root
  • Loading branch information
PercussiveElbow authored Oct 1, 2020
2 parents 51fd6fe + c64c04b commit ed00cee
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# Build image to compile the app
FROM crystallang/crystal:latest-alpine AS builder
RUN apk --no-cache add ca-certificates
RUN apk update && apk upgrade
RUN apk update && apk upgrade && apk --no-cache add ca-certificates
WORKDIR /app
COPY . /app
RUN adduser -S lowpriv
COPY ./src /app/src/
RUN crystal build --static --release /app/src/crobat_client.cr
FROM busybox:latest
WORKDIR /app

# Build the lightweight busybox based image
FROM scratch
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /app/crobat_client /app/crobat_client
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
RUN ln -s /etc/ssl/certs/ca-certificates.crt /etc/ssl/cert.pem
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/cert.pem
USER lowpriv
ENTRYPOINT ["/app/crobat_client"]

0 comments on commit ed00cee

Please sign in to comment.