-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
66 lines (47 loc) · 1.39 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
FROM python:3.9-slim as base
ENV PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random \
PYTHONUNBUFFERED=1
# create user with a home directory
ARG NB_USER=jovyan
ARG NB_UID=1000
ENV USER ${NB_USER}
ENV HOME /home/${NB_USER}
RUN apt-get update && apt-get install -y gcc libffi-dev g++
RUN adduser --disabled-password \
--gecos "Default user" \
--uid ${NB_UID} \
${NB_USER}
WORKDIR ${HOME}
FROM base as builder
ENV PIP_DEFAULT_TIMEOUT=100 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1 \
POETRY_VERSION=1.2.0
# create user with a home directory
ARG NB_USER=jovyan
ENV USER=${NB_USER} \
HOME=/home/${NB_USER}
USER ${USER}
RUN python -m venv .venv
ENV PATH="$HOME/.venv/bin:$PATH"
RUN pip install --verbose "poetry==$POETRY_VERSION"
COPY pyproject.toml poetry.lock ./
RUN poetry config virtualenvs.create false --local \
& poetry install --only main --no-root --no-interaction
FROM base as final
# create user with a home directory
ARG NB_USER=jovyan
ARG NB_UID=1000
ENV USER=${NB_USER} \
HOME=/home/${NB_USER}
USER ${USER}
COPY --from=builder $HOME/.venv $HOME/.venv
ENV PATH="$HOME/.venv/bin:$PATH"
COPY . ./classwise-calibration-experiments
USER root
RUN chown -R ${NB_UID} ${HOME}/classwise-calibration-experiments
USER ${NB_USER}
WORKDIR classwise-calibration-experiments
ENV PYTHONPATH="${HOME}/classwise-calibration-experiments:$PYTHONPATH"
CMD ["bash"]