-
Notifications
You must be signed in to change notification settings - Fork 22
/
Dockerfile
76 lines (71 loc) · 2.84 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
75
76
FROM materialsproject/devops:python-3.96.4 as base
FROM node:16.7.0-slim as node
FROM node as webpack-deps
RUN apt-get update && apt-get install -y --no-install-recommends \
git curl gnupg ca-certificates apt-transport-https \
&& apt-get clean
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update && apt-get install -y --no-install-recommends yarn
ENV NODE_ENV production
WORKDIR /app
COPY package.json .
RUN yarn install --production
FROM node as webpack
ENV NODE_ENV production
WORKDIR /app
COPY --from=webpack-deps /app/node_modules ./node_modules
COPY webpack.config.js .
COPY mpcontribs/portal/assets ./mpcontribs/portal/assets
RUN node --trace-deprecation node_modules/webpack/bin/webpack.js
FROM base as python-deps
RUN apt-get update && apt-get install -y --no-install-recommends gcc git g++ wget && apt-get clean
ENV PATH /root/.local/bin:$PATH
ENV PIP_FLAGS "--user --no-cache-dir --compile --use-feature=in-tree-build"
ARG MORE_PIP_FLAGS
ENV MORE_PIP_FLAGS=$MORE_PIP_FLAGS
COPY requirements.txt .
RUN pip install $PIP_FLAGS $MORE_PIP_FLAGS -r requirements.txt && \
python -m ipykernel install --user
RUN wget -q https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh && \
chmod +x wait-for-it.sh && mv wait-for-it.sh /root/.local/bin/
FROM base as python-builds
COPY --from=python-deps /root/.local/lib/python3.9/site-packages /root/.local/lib/python3.9/site-packages
COPY --from=python-deps /root/.local/bin /root/.local/bin
WORKDIR /app
COPY --from=webpack /app/dist dist
ENV NODE_ENV production
ENV PATH /root/.local/bin:$PATH
ENV PIP_FLAGS "--user --no-cache-dir --compile --use-feature=in-tree-build"
ARG MORE_PIP_FLAGS
ENV MORE_PIP_FLAGS=$MORE_PIP_FLAGS
ENV DJANGO_SETTINGS_FILE="settings.py"
COPY . .
RUN pip install $PIP_FLAGS $MORE_PIP_FLAGS .
RUN python manage.py collectstatic --noinput
FROM base
COPY --from=python-builds /root/.local/lib/python3.9/site-packages /root/.local/lib/python3.9/site-packages
COPY --from=python-builds /root/.local/bin /root/.local/bin
COPY --from=python-builds /app/static /app/static
COPY --from=python-builds /app/mpcontribs /app/mpcontribs
COPY --from=webpack /app/webpack-stats.json /app/webpack-stats.json
WORKDIR /app
ENV PATH=/root/.local/bin:$PATH \
DJANGO_SETTINGS_FILE="settings.py" \
PYTHONUNBUFFERED=1 \
API_CNAME=contribs-api.materialsproject.org \
API_PORT=5000 \
PORTAL_CNAME=contribs.materialsproject.org \
PORTAL_PORT=8080 \
RELOAD="" \
NWORKERS=2 \
MAX_REQUESTS=100000 \
MAX_REQUESTS_JITTER=10000
EXPOSE 8080 8082 8083 8085
COPY wsgi.py .
COPY settings.py .
COPY docker-entrypoint.sh .
COPY manage.py .
COPY start.sh .
ENTRYPOINT ["/app/docker-entrypoint.sh"]
CMD wait-for-it.sh $MPCONTRIBS_API_HOST -s -t 60 -- ./start.sh