Docker images for chicken-scheme development
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Kai Klingenberg 2c7b2ae4ff Add github workflow file. 3 years ago
.github/workflows Add github workflow file. 3 years ago
dockerfiles Update dockerfiles for chicken 5.3 3 years ago
.gitignore Initial commit 5 years ago
LICENSE Update dockerfiles for chicken 5.3 3 years ago
README.md Update dockerfiles for chicken 5.3 3 years ago
chicken-assemble.scm Initial commit 5 years ago

README.md

chicken-scheme dockerfiles

Dockerfiles useful for chicken scheme development. An optional custom chicken-assemble script is also provided, used to build projects in an opinionated, structured way.

You may pick a flavour built on top of popular linux distros:

docker pull plotter/chicken-scheme:5.3.0-alpine
docker pull plotter/chicken-scheme:5.3.0-debian
docker pull plotter/chicken-scheme:5.3.0-ubuntu
docker pull plotter/chicken-scheme:5.3.0-centos

How to use these images

Mount your source code directory into a running container to access chicken's REPL and/or compiler:

docker run --rm -it --workdir /src -v $(pwd):/src plotter/chicken-scheme

For truly static builds, prefer the alpine base image and set the proper compiler and linker flags:

FROM plotter/chicken-scheme:5.3.0-alpine
WORKDIR /src
COPY . .
RUN csc -static -L -static -L -no-pie main.scm
ENTRYPOINT ["/src/main"]

You may also choose to build a barebones scratch image containing only the desired binary:

FROM plotter/chicken-scheme:5.3.0-alpine as build
WORKDIR /src
COPY . .
RUN csc -static -L -static -L -no-pie main.scm

FROM scratch
COPY --from=build /src/main /bin/main
ENTRYPOINT ["/bin/main"]

chicken-assemble-based projects

chicken-assemble is a simple script which builds a single source file given a directory of source files, to be used for later compilation. The script wraps each file's contents into a module, and provides an unofficial local import used for referencing in-folder files as modules.

The following illustrates the appropriate directory structure, in case you decide to use chicken-assemble:

.
└── src
    ├── bar
    │   └── baz.scm
    ├── core.scm
    └── foo.scm

Where . is where you'd put non-source files like a Dockerfile, or license information.

src and core.scm are the default values for both arguments of chicken-assemble. They represent the source code folder and the main module, respectively. core.scm should declare a -main. The following is a possible listing of all these files contents (core.scm, foo.scm and bar.scm):

;; file: src/core.scm
(import scheme
        chicken.base
        (local foo))

(define (-main)
  (print (foo/do-thing)))

;; file: src/foo.scm
(import scheme
        chicken.base
        (local bar.baz))

(define (do-thing)
  (print "Doing a thing")
  bar.baz/thing)

;; file: src/bar/baz.scm
(import scheme)

(define thing "The nicest thing")

To assemble them all, run:

chicken-assemble src core > _app.scm

And the contents of _app.scm would turn out to be:

(module bar.baz * (import scheme) (define thing "The nicest thing"))
(module foo * (import scheme chicken.base (prefix bar.baz bar.baz/)) (define (do-thing) (print "Doing a thing") bar.baz/thing))
(module core * (import scheme chicken.base (prefix foo foo/)) (define (-main) (print (foo/do-thing))))
(import (chicken process-context) (prefix core core/))
(apply core/-main (command-line-arguments))