11# First stage : setup the system and environment
2- FROM eclipse-temurin:11-jre-noble as base
2+ FROM alpine:3.22 AS base
33
4+ # Install OpenJDK 11 and runtime dependencies
45RUN \
5- apt-get update && \
6- DEBIAN_FRONTEND=noninteractive apt-get install -y \
7- ca-certificates-java \
8- curl \
6+ apk add --no-cache \
7+ openjdk11-jre-headless \
98 graphviz \
9+ python3 \
10+ py3-pip \
11+ bash \
12+ libstdc++ \
13+ && \
14+ apk add --no-cache --virtual .build-deps \
1015 gcc \
16+ g++ \
17+ musl-dev \
18+ linux-headers \
1119 python3-dev \
1220 && \
13- rm -rf /var/lib/apt/lists/*
21+ pip3 install --no-cache-dir --break-system-packages jupyter jupyterlab && \
22+ find /usr/lib/python3.12 -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true && \
23+ find /usr/lib/python3.12 -type f -name '*.pyc' -delete && \
24+ find /usr/lib/python3.12 -type f -name '*.pyo' -delete && \
25+ find /usr/lib/python3.12/site-packages/babel/locale-data -mindepth 1 ! -name 'en_*' -a ! -name 'root.dat' -delete 2>/dev/null || true && \
26+ find /usr/lib/python3.12/site-packages -type d -name tests -exec rm -rf {} + 2>/dev/null || true && \
27+ find /usr/lib/python3.12/site-packages -type d -name testing -exec rm -rf {} + 2>/dev/null || true && \
28+ rm -rf /usr/lib/python3.12/site-packages/pip /usr/lib/python3.12/site-packages/setuptools && \
29+ apk del .build-deps
1430
15- RUN apt-get update && apt-get install -y python3-pip && rm -rf /var /lib/apt/lists/*
16- RUN pip3 install --no-cache-dir --break-system-packages jupyter jupyterlab
31+ ENV JAVA_HOME=/usr /lib/jvm/java-11-openjdk
32+ ENV PATH=$JAVA_HOME/bin:$PATH
1733
18- RUN useradd -ms /bin/bash bootcamp
34+ RUN adduser -D -s /bin/bash bootcamp
1935
2036ENV SCALA_VERSION=2.12.10
2137ENV ALMOND_VERSION=0.9.1
22-
38+ ENV COURSIER_VERSION=2.1.24
2339ENV COURSIER_CACHE=/coursier_cache
40+ ENV JUPYTER_CONFIG_DIR=/jupyter/config
41+ ENV JUPYTER_DATA_DIR=/jupyter/data
2442
25- ADD . /chisel-bootcamp/
43+ COPY . /chisel-bootcamp/
2644WORKDIR /chisel-bootcamp
2745
28- ENV JUPYTER_CONFIG_DIR=/jupyter/config
29- ENV JUPITER_DATA_DIR=/jupyter/data
30-
31- RUN mkdir -p $JUPYTER_CONFIG_DIR/custom
32- RUN cp source/custom.js $JUPYTER_CONFIG_DIR/custom/
33- RUN cp source/jupyter_server_config.py $JUPYTER_CONFIG_DIR/
46+ RUN mkdir -p $JUPYTER_CONFIG_DIR/custom && \
47+ cp source/custom.js $JUPYTER_CONFIG_DIR/custom/ && \
48+ cp source/jupyter_server_config.py $JUPYTER_CONFIG_DIR/
3449
3550# Second stage - download Scala requirements and the Scala kernel
36- FROM base as intermediate-builder
51+ FROM base AS intermediate-builder
52+
53+ ARG TARGETARCH
3754
3855RUN mkdir /coursier_cache
3956
57+ # Install glibc for ARM64 coursier binary (x86-64 uses static musl build)
58+ RUN \
59+ if [ "$TARGETARCH" = "arm64" ]; then \
60+ apk add --no-cache wget gcompat libstdc++ && \
61+ wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
62+ wget -q https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.35-r1/glibc-2.35-r1.apk && \
63+ apk --no-cache --force-overwrite add glibc-2.35-r1.apk && \
64+ rm glibc-2.35-r1.apk && \
65+ ln -s /lib/ld-musl-aarch64.so.1 /lib/ld-linux-aarch64.so.1 2>/dev/null || true; \
66+ fi
67+
4068RUN \
41- curl -L -o coursier https://git.io/coursier-cli && \
69+ apk add --no-cache curl && \
70+ case "$TARGETARCH" in \
71+ amd64|"" ) \
72+ CS_URL="https://github.com/coursier/coursier/releases/download/v${COURSIER_VERSION}/cs-x86_64-pc-linux-static.gz" ;; \
73+ arm64) \
74+ CS_URL="https://github.com/VirtusLab/coursier-m1/releases/download/v${COURSIER_VERSION}/cs-aarch64-pc-linux.gz" ;; \
75+ *) \
76+ echo "Unsupported architecture: $TARGETARCH" && exit 1 ;; \
77+ esac && \
78+ curl -fL --retry 3 "$CS_URL" | gzip -d > coursier && \
4279 chmod +x coursier && \
4380 ./coursier \
4481 bootstrap \
@@ -47,23 +84,21 @@ RUN \
4784 --default=true \
4885 -o almond && \
4986 ./almond --install --global && \
50- \ r m -rf almond couriser /root/.cache/coursier
87+ rm -rf almond coursier /root/.cache/coursier
5188
5289# Execute a notebook to ensure Chisel is downloaded into the image for offline work
5390# Disabled: dotvisualizer has JSON4s compatibility issues with Chisel 3.6
5491# Dependencies are already cached via coursier bootstrap above
5592# RUN jupyter nbconvert --to notebook --output=/tmp/0_demo --execute 0_demo.ipynb
5693
5794# Last stage
58- FROM base as final
95+ FROM base AS final
5996
60- # copy the Scala requirements and kernel into the image
61- COPY --from=intermediate-builder /coursier_cache/ /coursier_cache/
62- COPY --from=intermediate-builder /usr/local/share/jupyter/kernels/scala/ /usr/local/share/jupyter/kernels/scala/
97+ # copy the Scala requirements and kernel into the image
98+ COPY --from=intermediate-builder --chown=bootcamp:bootcamp /coursier_cache/ /coursier_cache/
99+ COPY --from=intermediate-builder --chown=bootcamp:bootcamp /usr/local/share/jupyter/kernels/scala/ /usr/local/share/jupyter/kernels/scala/
63100
64- RUN chown -R bootcamp:bootcamp /chisel-bootcamp
65- RUN chown -R bootcamp:bootcamp /jupyter
66- RUN chown -R bootcamp:bootcamp /coursier_cache
101+ RUN chown -R bootcamp:bootcamp /chisel-bootcamp /jupyter
67102
68103USER bootcamp
69104WORKDIR /chisel-bootcamp
0 commit comments