-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
74 lines (60 loc) · 1.94 KB
/
Dockerfile
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
# syntax = docker/dockerfile:1.3
# The build stage
# ---------------
FROM python:3.9-bullseye as build-stage
# VULN_SCAN_TIME=2022-08-08_05:22:22
WORKDIR /build-stage
# set pip's cache directory using this environment variable, and use
# ARG instead of ENV to ensure its only set when the image is built
ARG PIP_CACHE_DIR=/tmp/pip-cache
# Build wheels
# These are mounted into the final image for installation
COPY requirements.txt requirements.txt
RUN --mount=type=cache,target=${PIP_CACHE_DIR} \
pip install build \
&& pip wheel -r requirements.txt
# The final stage
# ---------------
FROM python:3.9-slim-bullseye
ARG NB_USER=jovyan
ARG NB_UID=1000
ARG HOME=/home/jovyan
ENV DEBIAN_FRONTEND=noninteractive
RUN adduser --disabled-password \
--gecos "Default user" \
--uid ${NB_UID} \
--home ${HOME} \
--force-badname \
${NB_USER}
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
# misc network utilities
curl \
dnsutils \
git \
# misc other utilities
less \
vim \
# requirement for pycurl
libcurl4 \
# requirement for using a local sqlite database
sqlite3 \
tini \
&& rm -rf /var/lib/apt/lists/*
# set pip's cache directory using this environment variable, and use
# ARG instead of ENV to ensure its only set when the image is built
ARG PIP_CACHE_DIR=/tmp/pip-cache
# install wheels built in the build-stage
COPY requirements.txt /tmp/requirements.txt
RUN --mount=type=cache,target=${PIP_CACHE_DIR} \
--mount=type=cache,from=build-stage,source=/build-stage,target=/tmp/wheels \
pip install \
--find-links=/tmp/wheels/ \
-r /tmp/requirements.txt
WORKDIR /srv/jupyterhub
RUN chown ${NB_USER}:${NB_USER} /srv/jupyterhub
USER ${NB_USER}
EXPOSE 8081
ENTRYPOINT ["tini", "--"]
CMD ["jupyterhub", "--config", "/usr/local/etc/jupyterhub/jupyterhub_config.py"]