Skip to content

Instantly share code, notes, and snippets.

@watsy0007
Created December 28, 2019 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save watsy0007/3e54cb13014719e9fa6dc2f83b849a06 to your computer and use it in GitHub Desktop.
Save watsy0007/3e54cb13014719e9fa6dc2f83b849a06 to your computer and use it in GitHub Desktop.
crystal smallest docker file
# FROM alpine:latest as builder
# RUN apk add -u crystal shards libc-dev
# WORKDIR /src
# COPY . .
# RUN crystal build --release src/api_demo.cr -o /src/api_demo
# FROM busybox
# WORKDIR /app
# COPY --from=builder /src/api_demo /app/api_demo
# ENTRYPOINT ["/app/api_demo"]
FROM crystallang/crystal:latest as builder
WORKDIR /src
COPY . .
RUN shards build --production --progress --verbose --warnings=all
RUN ldd ./bin/api_demo | tr -s '[:blank:]' '\n' | grep '^/' | xargs -I % sh -c 'mkdir -p $(dirname deps%); cp % deps%;'
RUN find ./deps/
RUN ls /src/bin
FROM scratch
COPY --from=builder /src/deps /
COPY --from=builder /lib/x86_64-linux-gnu/libnss_dns.so.* /lib/x86_64-linux-gnu/
COPY --from=builder /lib/x86_64-linux-gnu/libresolv.so.* /lib/x86_64-linux-gnu/
COPY --from=builder /src/bin/api_demo /app
ENTRYPOINT [ "/app" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment