-
Notifications
You must be signed in to change notification settings - Fork 1
/
Containerfile
132 lines (108 loc) · 3.93 KB
/
Containerfile
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#####################################################################################
# Build Step
# Build the frontend and backend parts of the extension
#####################################################################################
FROM ubuntu:24.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# install system dependencies
RUN apt update && \
apt install -y curl unzip git ca-certificates python3-dev python3-pip && \
curl -fsSL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh && \
bash nodesource_setup.sh && \
apt install -y nodejs && \
apt clean && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/cache/apt/archives/*
# install yarn
RUN npm install -g corepack && \
corepack enable && \
yarn set version stable
WORKDIR /tmp/package
# install python dependencies
RUN pip3 install --break-system-packages jupyterlab build
COPY requirements/main.txt /tmp/requirements.txt
RUN pip3 install --break-system-packages -r /tmp/requirements.txt && \
rm -f /tmp/requirements.txt
# build the extension
COPY . /tmp/package/waldiez_jupyter
WORKDIR /tmp/package/waldiez_jupyter
RUN touch yarn.lock && \
yarn install && \
yarn build:lib:prod && \
yarn build && \
python3 -m build
#####################################################################################
# Final image
#####################################################################################
FROM python:3.12-slim
LABEL maintainer="waldiez <[email protected]>"
LABEL org.opencontainers.image.source="quay.io/waldiez/jupyter"
LABEL org.opencontainers.image.title="waldiez/jupyter"
LABEL org.opencontainers.image.description="JupyterLab with waldiez extension installed"
# set environment variables
ENV PYTHONUNBUFFERED=1
ENV DEBIAN_FRONTEND="noninteractive"
ENV DEBCONF_NONINTERACTIVE_SEEN=true
# install system dependencies
RUN apt update && \
apt upgrade -y && \
apt install -y --no-install-recommends \
tzdata \
locales \
bzip2 \
ca-certificates \
build-essential \
wget \
fonts-liberation \
git \
sudo \
openssl \
pandoc \
curl \
tini \
zip \
unzip && \
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
locale-gen en_US.UTF-8 && \
apt clean && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/cache/apt/archives/*
ENV LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8 \
LC_ALL=en_US.UTF-8 \
LC_CTYPE=en_US.UTF-8 \
TZ=Etc/UTC
# install nodejs
RUN curl -fsSL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh && \
bash nodesource_setup.sh && \
apt install -y nodejs && \
apt clean && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/cache/apt/archives/*
RUN sed -i 's/^#force_color_prompt=yes/force_color_prompt=yes/' /etc/skel/.bashrc
# add a non-root user
ARG GROUP_ID=1000
ENV GROUP_ID=${GROUP_ID}
RUN addgroup --system --gid ${GROUP_ID} user
ARG USER_ID=1000
ENV USER_ID=${USER_ID}
RUN adduser --disabled-password --gecos '' --shell /bin/bash --uid ${USER_ID} --gid ${GROUP_ID} user
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
RUN mkdir -p /home/user/notebooks /home/user/tmp /home/user/.local/bin && \
chown -R user:user /home/user
ENV PATH=/home/user/.local/bin:${PATH}
USER user
RUN pip install --upgrade pip jupyterlab ipywidgets ipykernel
COPY --chown=user:user scripts /home/user/scripts
RUN chmod +x /home/user/scripts/start.sh
COPY --from=builder --chown=user:user /tmp/package/waldiez_jupyter/dist/*.whl /home/user/tmp/
RUN pip install --user /home/user/tmp/*.whl && \
rm -rf /home/user/tmp
RUN mkdir -p /home/user/.local/share/jupyter/lab/settings && \
echo '{"@jupyterlab/apputils-extension:themes":{"theme": "JupyterLab Dark"}}' > /home/user/.local/share/jupyter/lab/settings/overrides.json
EXPOSE 8888
VOLUME /home/user/notebooks
WORKDIR /home/user/notebooks
ENV TINI_SUBREAPER=true
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["/home/user/scripts/start.sh"]