-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (46 loc) · 2.07 KB
/
Dockerfile
File metadata and controls
58 lines (46 loc) · 2.07 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
# Note, to download from ghcr.io you may need to authenticate with docker login, e.g.
# echo $(gh auth token) | docker login ghcr.io -u "$(gh api user | jq -r .login)" --password-stdin
# Build latest just from source using cargo
FROM rust:slim AS just-builder
RUN cargo install just
FROM ghcr.io/astral-sh/uv:python3.13-trixie-slim
# Create user for binder
ARG NB_USER=notebook-user
ARG NB_UID=1001
ENV USER=${NB_USER} \
HOME=/home/${NB_USER}
ENV UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy \
UV_TOOL_BIN_DIR=/usr/local/bin \
UV_CACHE_DIR=${HOME}/.cache/uv
RUN adduser --disabled-password \
--gecos "Default user" \
--uid ${NB_UID} \
${NB_USER} && \
mkdir -p ${HOME} && \
chown -R ${USER}:${USER} ${HOME} && \
chown -R ${USER}:${USER} /usr/local/bin /usr/local/lib
# Apt dependencies for gdsfactory & KLayout
RUN apt-get update -y && \
apt-get install -y --no-install-recommends git=1:2.47.3-0+deb13u1 libexpat1=2.7.1-2 libexpat1-dev=2.7.1-2 && \
rm -rf /var/lib/apt/lists/*
# Copy just binary from builder stage
COPY --from=just-builder /usr/local/cargo/bin/just /usr/local/bin/just
WORKDIR ${HOME}
USER ${USER}
# First install only dependencies with cache mount
RUN --mount=type=cache,uid=${NB_UID},gid=${NB_UID},target=${HOME}/.cache/uv \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --no-install-project --all-extras && \
uv pip install jupyterlab jupytext
# Copy source code, install project and convert jupytext scripts to notebooks
COPY --chown=${USER}:${USER} . ${HOME}
RUN --mount=type=cache,uid=${NB_UID},gid=${NB_UID},target=${HOME}/.cache/uv \
just install && \
uv run jupytext --to ipynb qpdk/samples/**/*.py
# Set PATH to include virtual environment
ENV PATH="${HOME}/.venv/bin:$PATH"
# Expose Jupyter Lab port
EXPOSE 8888
SHELL ["/bin/bash", "-c"]
CMD ["/usr/local/bin/uv", "run", "--with", "jupyter", "jupyter", "lab", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--allow-root", "--ServerApp.token=''", "--ServerApp.password=''"]