-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathContainerfile.dev
More file actions
207 lines (185 loc) · 7.12 KB
/
Containerfile.dev
File metadata and controls
207 lines (185 loc) · 7.12 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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#####################################################################################
# Build an image using @waldiez/react and "waldiez" from git or from a local path
#####################################################################################
# cspell:disable
FROM python:3.13-slim
LABEL maintainer="waldiez <development@waldiez.io>"
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 \
libcairo2-dev \
libpango1.0-dev \
libjpeg-dev \
libgif-dev \
librsvg2-dev \
wget \
fonts-liberation \
git \
sudo \
openssl \
pandoc \
curl \
tini \
zip \
unzip \
graphviz \
jq \
libcairo2-dev \
libpango1.0-dev \
libjpeg-dev \
libgif-dev \
librsvg2-dev \
libgdk-pixbuf-xlib-2.0-0 \
libnspr4 \
libnss3 \
libx11-xcb1 \
libxcomposite1 \
libxdamage1 \
libxrandr2 \
xdg-utils \
xvfb && \
curl -fsSL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh && \
bash nodesource_setup.sh && \
rm nodesource_setup.sh && \
apt install -y nodejs && \
npm install -g corepack && \
corepack enable && \
yarn set version stable && \
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
# Add ChromeDriver and Chrome
RUN ARCH=$(uname -m) && \
if [ "$ARCH" = "x86_64" ]; then \
CHROME_ARCH="linux64"; \
elif [ "$ARCH" = "aarch64" ]; then \
CHROME_ARCH="linux64"; \
else \
echo "Unsupported architecture: $ARCH" && exit 1; \
fi && \
LATEST_VERSION=$(curl -s "https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json" | \
jq -r '.channels.Stable.version') && \
echo "Installing Chrome and ChromeDriver version: $LATEST_VERSION for $CHROME_ARCH" && \
curl -Lo /tmp/chrome.zip "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/${LATEST_VERSION}/${CHROME_ARCH}/chrome-linux64.zip" && \
unzip /tmp/chrome.zip -d /opt && \
ln -sf /opt/chrome-linux64/chrome /usr/bin/google-chrome && \
curl -Lo /tmp/chromedriver.zip "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/${LATEST_VERSION}/${CHROME_ARCH}/chromedriver-linux64.zip" && \
unzip /tmp/chromedriver.zip -d /usr/local/bin && \
mv /usr/local/bin/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver && \
chmod +x /usr/local/bin/chromedriver && \
rm -rf /tmp/chrome.zip /tmp/chromedriver.zip /usr/local/bin/chromedriver-linux64
# Add GeckoDriver (for Firefox)
RUN ARCH=$(uname -m) && \
if [ "$ARCH" = "x86_64" ]; then \
GECKO_ARCH="linux64"; \
elif [ "$ARCH" = "aarch64" ]; then \
GECKO_ARCH="linux-aarch64"; \
else \
echo "Unsupported architecture: $ARCH" && exit 1; \
fi && \
curl -fsSL https://packages.mozilla.org/apt/repo-signing-key.gpg | \
gpg --dearmor -o /etc/apt/trusted.gpg.d/mozilla.gpg && \
echo "deb https://packages.mozilla.org/apt mozilla main" > /etc/apt/sources.list.d/mozilla.list && \
apt-get update && \
apt-get install -y firefox && \
FIREFOX_VERSION="$(dpkg-query -W -f='${Version}\n' firefox | sed 's/~.*//; s/-.*//')"; \
echo "Firefox version: $FIREFOX_VERSION" && \
GECKO_VERSION=""; \
for i in 1 2 3; do \
GECKO_VERSION=$(curl -sL -o /dev/null -w '%{url_effective}' https://github.com/mozilla/geckodriver/releases/latest | awk -F/ '{print $NF}'); \
if [ "$GECKO_VERSION" != "null" ] && [ -n "$GECKO_VERSION" ]; then break; fi; \
echo "Retrying fetch of GeckoDriver version... ($i)"; \
sleep 2; \
done && \
if [ -z "$GECKO_VERSION" ] || [ "$GECKO_VERSION" = "null" ]; then \
echo "Failed to fetch GeckoDriver version" >&2; exit 1; \
fi && \
echo "GeckoDriver version: $GECKO_VERSION for $GECKO_ARCH" && \
curl -Lo /tmp/geckodriver.tar.gz "https://github.com/mozilla/geckodriver/releases/download/${GECKO_VERSION}/geckodriver-${GECKO_VERSION}-${GECKO_ARCH}.tar.gz" && \
tar -xzf /tmp/geckodriver.tar.gz -C /usr/local/bin && \
chmod +x /usr/local/bin/geckodriver && \
rm /tmp/geckodriver.tar.gz && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN npm install -g corepack
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} waldiez
ARG USER_ID=1000
ENV USER_ID=${USER_ID}
RUN adduser --disabled-password --gecos '' --shell /bin/bash --uid ${USER_ID} --gid ${GROUP_ID} waldiez
RUN echo "waldiez ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-waldiez
RUN mkdir -p /home/waldiez/notebooks /home/waldiez/tmp /home/waldiez/.local/bin && \
chown -R waldiez:waldiez /home/waldiez
# Switch to the non-root user
USER waldiez
ENV PATH=/home/waldiez/.local/bin:${PATH}
ENV PIP_BREAK_SYSTEM_PACKAGES=1
# Set display for headless operations if needed
ENV DISPLAY=:99
# install bun
RUN curl -fsSL https://bun.sh/install | bash
ENV PATH=/home/waldiez/.bun/bin:${PATH}
COPY --chown=waldiez:waldiez . /home/waldiez/app
WORKDIR /home/waldiez/app
ARG REACT_BRANCH=main
ARG REACT_COMMIT=
ARG PYTHON_BRANCH=main
ARG PYTHON_COMMIT=
# api.waldiez.io
ARG API_URL_BASE="api"
ENV REACT_BRANCH=${REACT_BRANCH}
ENV REACT_COMMIT=${REACT_COMMIT}
ENV PYTHON_BRANCH=${PYTHON_BRANCH}
ENV PYTHON_COMMIT=${PYTHON_COMMIT}
ENV API_URL_BASE=${API_URL_BASE}
RUN echo "Building waldiez/jupyter with the following parameters:" \
&& echo "REACT_BRANCH=${REACT_BRANCH}" \
&& echo "REACT_COMMIT=${REACT_COMMIT}" \
&& echo "PYTHON_BRANCH=${PYTHON_BRANCH}" \
&& echo "PYTHON_COMMIT=${PYTHON_COMMIT}" \
&& echo "API_URL_BASE=${API_URL_BASE}"
# build the application
RUN sh /home/waldiez/app/scripts/build_dev.sh --react-branch "${REACT_BRANCH}" --react-commit "${REACT_COMMIT}" --python-commit "${PYTHON_COMMIT}" --python-branch "${PYTHON_BRANCH}" --api-url-base "${API_URL_BASE}" && \
rm -rf /home/waldiez/app
COPY --chown=waldiez:waldiez scripts/start.sh /home/waldiez/app/start.sh
RUN chmod +x /home/waldiez/app/start.sh
RUN mkdir -p /home/waldiez/.local/share/jupyter/lab/settings && \
cat > /home/waldiez/.local/share/jupyter/lab/settings/overrides.json <<EOF
{
"@jupyterlab/apputils-extension:themes": {
"theme": "JupyterLab Dark"
},
"@jupyterlab/terminal-extension:plugin": {
"shellCommand": "/bin/bash"
}
}
EOF
EXPOSE 8888
VOLUME /home/waldiez/notebooks
WORKDIR /home/waldiez/notebooks
ENV TINI_SUBREAPER=true
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["/home/waldiez/app/start.sh"]