Skip to content

Instantly share code, notes, and snippets.

@WJWH
Last active August 25, 2019 08:24
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WJWH/2d4cb80f2799256e8703d2e904d0b707 to your computer and use it in GitHub Desktop.
Save WJWH/2d4cb80f2799256e8703d2e904d0b707 to your computer and use it in GitHub Desktop.
Generic dockerfile for statically compiled Crystal applications
# See https://wjwh.eu/posts/2019-07-21-static-crystal-images.html for the reasoning behind each line
# Build stage
FROM durosoft/crystal-alpine:0.28.0 as build
COPY shard.yml shard.yml
RUN shards install --production
COPY . ./
RUN crystal build src/my_app.cr --release --static
# Release stage
FROM alpine:3.10
COPY --from=0 my_app my_app
EXPOSE 3000 # Or whichever other port you want exposed, if any
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment