-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
68 lines (57 loc) · 1.8 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
FROM node:16.20.2 as node
ENV NODE_ENV=production
RUN apt-get update && apt-get install libelf1 -y
COPY . /src
WORKDIR /src
RUN yarn install --frozen-lockfile --ignore-engines --prefer-offline && \
node node_modules/webpack/bin/webpack.js --config webpack.config.prod.js --bail
FROM python:3.9.19-bullseye AS base
# Add package files, install updated node and pip
WORKDIR /tmp
# Install packages
COPY apt.txt /tmp/apt.txt
RUN apt-get update && \
apt-get install -y $(grep -vE "^\s*#" apt.txt | tr "\n" " ") && \
apt-get update && \
apt-get install libpq-dev postgresql-client -y && \
apt-get clean && \
apt-get purge
# Install pip
RUN curl --silent --location https://bootstrap.pypa.io/get-pip.py | python3 -
# Add, and run as, non-root user.
RUN mkdir /src
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'
# Install poetry
RUN pip install "poetry==$POETRY_VERSION"
# Install project packages
COPY pyproject.toml /src
COPY poetry.lock /src
WORKDIR /src
RUN poetry install --no-dev
# Add project
COPY . /src
RUN chown -R mitodl:mitodl /src
USER mitodl
EXPOSE 8089
ENV PORT 8089
CMD uwsgi uwsgi.ini
FROM base AS production
LABEL maintainer "ODL DevOps <[email protected]>"
ENV DEBUG=False PYTHONUNBUFFERED=true
COPY --from=node --chown=mitodl:mitodl /src/static /src/static
COPY --from=node --chown=mitodl:mitodl /src/webpack-stats.json /src
USER mitodl
# Second stage build installs reqs needed only for develoment envs
# Invoke 'requirements.txt' again because 'test_requirements.txt' doesn't
# like to run alone for some reasont
FROM base AS development
USER root
RUN poetry install
USER mitodl