Added dockerfile

This commit is contained in:
retropikzel 2025-07-20 10:32:39 +03:00
parent 079be1d1a3
commit d4fe28f656
3 changed files with 53 additions and 18 deletions

View File

@ -1,12 +1,23 @@
FROM schemers/chibi:head
FROM schemers/chibi:head AS build
RUN mkdir -p ${HOME}/.snow && echo "()" > ${HOME}/.snow/config.scm
RUN apt-get update && apt-get install -y \
build-essential ca-certificates git make libffi-dev
RUN git clone https://github.com/ashinn/chibi-scheme.git --depth=1 \
&& cd chibi-scheme && make -j 16 && make -j 16 install
build-essential \
ca-certificates \
git \
make \
libffi-dev \
pandoc \
chicken-bin
RUN mkdir -p /opt/compile-r7rs
RUN mkdir -p /opt/compile-r7rs/bin
RUN mkdir -p /opt/compile-r7rs/lib
RUN chicken-install r7rs
WORKDIR /builddir
COPY Makefile .
COPY compile-r7rs.scm .
COPY libs/ libs/
RUN make && make install
WORKDIR /workdir
RUN mkdir -p ${HOME}/.snow && echo "()" > ${HOME}/.snow/config.scm
RUN make PREFIX=/opt/compile-r7rs build-chicken-static && make PREFIX=/opt/compile-r7rs install
FROM debian:bookworm-slim
COPY --from=build /opt/compile-r7rs /opt/compile-r7rs
ENV PATH=/opt/compile-r7rs/bin:${PATH}

View File

@ -16,6 +16,26 @@ build: deps
echo "#!/bin/sh" > compile-r7rs
echo "chibi-scheme -A ${PREFIX}/lib/compile-r7rs ${PREFIX}/lib/compile-r7rs/main.scm \"\$$@\"" >> compile-r7rs
build-chicken-static: deps
csc -R r7rs -X r7rs -I snow/foreign/c -static -c -J -unit foreign.c -o foreign.c.o deps/foreign-c/foreign/c.sld
ar rcs foreign.c.a foreign.c.o
csc -R r7rs -X r7rs -static -c -J -unit srfi-170 -o srfi-170.o deps/foreign-c-srfi-170/srfi/170.sld
ar rcs srfi-170.a srfi-170.o
csc -R r7rs -X r7rs -static -c -J -unit libs.util -o libs.util.o libs/util.sld
ar rcs libs.util.a libs.util.o
csc -R r7rs -X r7rs -static -c -J -unit libs.library-util -o libs.library-util.o libs/library-util.sld
ar rcs libs.library-util.a libs.library-util.o
csc -R r7rs -X r7rs -static -c -J -unit libs.data -o libs.data.o libs/data.sld
ar rcs libs.data.a libs.data.o
csc -R r7rs -X r7rs -static \
-o compile-r7rs \
-uses libs.util \
-uses libs.library-util \
-uses libs.data \
-uses foreign.c \
-uses srfi-170 \
compile-r7rs.scm
deps:
mkdir -p deps
git clone https://git.sr.ht/~retropikzel/foreign-c deps/foreign-c --depth=1

View File

@ -294,21 +294,25 @@ tried to compile them in wrong order you would run:
## Usage with Docker
<a name="#usage-with-docker"></a>
Here is a sample Dockerfile to get you started.
The project has
[docker image](https://hub.docker.com/repository/docker/retropikzel1/compile-r7rs/general).
ARG COMPILE_R7RS=chibi
FROM schemers/${COMPILE_R7RS}
RUN apt-get update && apt-get install -y make git chicken-bin
RUN chicken-install r7rs
ARG COMPILE_R7RS=chibi
ENV COMPILE_R7RS=${COMPILE_R7RS}
RUN git clone https://git.sr.ht/~retropikzel/compile-r7rs && cd compile-r7rs && make && make install
It is statically built with Chicken scheme and installed under /opt/compile-r7rs,
so it can be copied in your Dockerfile.
Here is a sample Dockerfile to get you started:
ARG SCHEME=chibi
FROM schemers/${SCHEME}
COPY --from=retropikzel1/compile-r7rs /opt/compile-r7rs /opt/compile-r7rs
ENV PATH=/opt/compile-r7rs/bin:${PATH}
ENV COMPILE_R7RS=${SCHEME}
To use this run:
export COMPILE_R7RS=<your scheme>
docker build --build-arg COMPILE_R7RS=${COMPILE_R7RS} --tag=compile-r7rs-${COMPILE_R7RS} .
docker run -v "${PWD}":/workdir -w /workdir -t compile-r7rs-${COMPILE_R7RS} sh -c "compile-r7rs -I -o main ./snow main.scm"
docker build --build-arg SCHEME=${SCHEME} --tag=sometag .
docker run -v "${PWD}":/workdir -w /workdir -t sometag sh -c "compile-r7rs -I . -o main ./snow main.scm"
## Usual RnRS projects
<a name="#usual-rnrs-projects"></a>