-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (61 loc) · 2.91 KB
/
Dockerfile
File metadata and controls
75 lines (61 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
ARG CUDA_VERSION="12.8"
ARG ENVIRONMENT="ml"
# ============================================================
# Stage 1: Build - install all dependencies via pixi
# ============================================================
FROM ghcr.io/prefix-dev/pixi:noble-cuda-13.0.0 AS build
ARG CUDA_VERSION
ARG ENVIRONMENT
WORKDIR /app
COPY pixi.toml pixi.lock ./
ENV CONDA_OVERRIDE_CUDA=$CUDA_VERSION
RUN pixi install --manifest-path /app/pixi.toml --locked --environment $ENVIRONMENT
# Generate entrypoint from pixi shell-hook
RUN echo "#!/bin/bash" > /app/entrypoint.sh && \
echo "export PYTHONNOUSERSITE=1" >> /app/entrypoint.sh && \
echo "JUPYTER_CONFIG_DIR=/app/.jupyter/config" >> /app/entrypoint.sh && \
echo "JUPYTER_DATA_DIR=/app/.jupyter/data" >> /app/entrypoint.sh && \
echo "JUPYTER_RUNTIME_DIR=/app/.jupyter/runtime" >> /app/entrypoint.sh && \
pixi shell-hook --manifest-path /app/pixi.toml \
--environment $ENVIRONMENT -s bash >> /app/entrypoint.sh && \
echo 'exec "$@"' >> /app/entrypoint.sh
# ============================================================
# Stage 2: Final runtime image
# ============================================================
FROM ghcr.io/prefix-dev/pixi:noble-cuda-13.0.0 AS final
ARG ENVIRONMENT
WORKDIR /app
# Copy pixi environment (the only large layer)
COPY --from=build /app/.pixi/envs/$ENVIRONMENT /app/.pixi/envs/$ENVIRONMENT
COPY --from=build /app/pixi.toml /app/pixi.toml
COPY --from=build /app/pixi.lock /app/pixi.lock
COPY --from=build /app/.pixi/.gitignore /app/.pixi/.gitignore
COPY --from=build /app/.pixi/.condapackageignore /app/.pixi/.condapackageignore
COPY --from=build --chmod=0755 /app/entrypoint.sh /app/entrypoint.sh
# Jupyter configuration
COPY config/jupyter_notebook_config.py /usr/local/etc/jupyter_notebook_config.py
COPY --chmod=0755 config/SetupPrivateJupyterLab.sh /usr/local/bin/SetupPrivateJupyterLab.sh
RUN pixi self-update --version 0.65.0
# Singularity/Apptainer host GPU driver compatibility
# see https://github.com/singularityware/singularity/issues/611
RUN mkdir -p /host-libs && \
echo "/host-libs/" > /etc/ld.so.conf.d/000-host-libs.conf && \
ldconfig
# Workspace directory
RUN mkdir -p /workspace
# match jupyter configuration
RUN mkdir -p /app/.jupyter/{config,data,runtime} && \
chmod -R a+rwx /app/.jupyter && \
chmod -R a+rwx /app/.pixi && \
chmod a+rwx /app/pixi.toml /app/pixi.lock
# User sync script (MaNIAC Lab infrastructure)
RUN /app/entrypoint.sh curl -fsSL -o /usr/local/bin/sync_users_debian.sh \
https://raw.githubusercontent.com/maniaclab/ci-connect-api/master/resources/provisioner/sync_users_debian.sh && \
chmod +x /usr/local/bin/sync_users_debian.sh
# Disable user site-packages
ENV PYTHONNOUSERSITE=1
# Force Jupyter to ignore user dirs
ENV JUPYTER_CONFIG_DIR=/app/.jupyter/config
ENV JUPYTER_DATA_DIR=/app/.jupyter/data
ENV JUPYTER_RUNTIME_DIR=/app/.jupyter/runtime
ENTRYPOINT ["/app/entrypoint.sh"]