-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
69 lines (52 loc) · 1.55 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
FROM python:3.9.18 as base
LABEL maintainer "ODL DevOps <mitx-devops@mit.edu>"
# Add package files, install updated node and pip
WORKDIR /tmp
# Install packages and add repo needed for postgres 9.6
COPY apt.txt /tmp/apt.txt
RUN apt-get update
RUN apt-get install -y $(grep -vE "^\s*#" apt.txt | tr "\n" " ")
# pip
RUN curl --silent --location https://bootstrap.pypa.io/get-pip.py | python3 -
# Add, and run as, non-root user.
RUN mkdir /app
RUN adduser --disabled-password --gecos "" mitodl
RUN mkdir /var/media && chown -R mitodl:mitodl /var/media
# Poetry env configuration
ENV \
# poetry:
POETRY_VERSION=1.5.1 \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_CACHE_DIR='/tmp/cache/poetry' \
POETRY_HOME='/home/mitodl/.local' \
VIRTUAL_ENV="/opt/venv"
ENV PATH="$VIRTUAL_ENV/bin:$POETRY_HOME/bin:$PATH"
# Install project packages
COPY pyproject.toml /app
COPY poetry.lock /app
RUN chown -R mitodl:mitodl /app
RUN mkdir ${VIRTUAL_ENV} && chown -R mitodl:mitodl ${VIRTUAL_ENV}
USER mitodl
RUN curl -sSL https://install.python-poetry.org \
| \
POETRY_VERSION=${POETRY_VERSION} \
POETRY_HOME=${POETRY_HOME} \
python3 -q
WORKDIR /app
RUN python3 -m venv $VIRTUAL_ENV
RUN poetry install
# Add project
COPY . /app
USER root
RUN apt-get clean && apt-get purge
# Set pip cache folder, as it is breaking pip when it is on a shared volume
ENV XDG_CACHE_HOME /tmp/.cache
FROM base as django
USER mitodl
FROM base as django-server
EXPOSE 8013
ENV PORT 8013
CMD uwsgi uwsgi.ini
FROM base as jupyter-notebook
RUN pip install --force-reinstall jupyter
USER mitodl