Skip to content

Instantly share code, notes, and snippets.

@samdphillips
Created June 21, 2021 16:24
Show Gist options
  • Save samdphillips/4425f043be68cf11b66163313cc67379 to your computer and use it in GitHub Desktop.
Save samdphillips/4425f043be68cf11b66163313cc67379 to your computer and use it in GitHub Desktop.
A very basic Dockerfile for Racket projects
FROM racket/racket:8.1-full AS build
WORKDIR /src/my-project
RUN raco pkg config --set catalogs \
https://download.racket-lang.org/releases/8.1/catalog/ \
https://racksnaps.defn.io/snapshots/2021/05/27/catalog/
RUN raco pkg install --auto --batch $ALL_THE_PACKAGES_I_NEED
COPY . /src/my-project
RUN raco test -x .
RUN raco exe --vv ++lib $DYNAMIC_REQUIRE_LIBS -o my-project main.rkt
RUN raco distribute /my-project my-project
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/UTC
RUN apt update && apt install -y dumb-init ca-certificates openssl tzdata && apt clean && rm -rf /var/lib/apt/lists/*
COPY --from=build /ct-truck /ct-truck
CMD ["dumb-init", "-v", "-r", "15:2", "/my-project/bin/my-project"]
@branneman
Copy link

If you are specifying dependencies in your info.rkt:

#lang info

(define deps '("markdown" "tzinfo"))

You can use this line to automatically populate the $ALL_THE_PACKAGES_I_NEED variable:

RUN raco pkg install --auto --batch \
    $(racket -e "(require setup/getinfo) (for-each (lambda (s) (display s) (display \" \")) ((get-info/full \".\") 'deps))")

@samdphillips
Copy link
Author

If you are specifying dependencies in your info.rkt:

That's one of the shortcomings of the project this was taken from, no info.rkt file yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment