-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
73 lines (54 loc) · 2.09 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
# # Build step #0: build custom plotly to fix heatmap bug
# NOTE: this is commented out since the repo ships with this and it takes a long time to build.
# FROM node:16-buster as plotly-step
#
# # -- Custom build Plotly.js so we can load in a specific version of regl-scatter2d which fixes a slow-heatmap bug
# WORKDIR /
# RUN git clone --depth 1 --branch v2.26.2 https://github.com/plotly/plotly.js.git
# WORKDIR /plotly.js
# # Install dependencies using the cache mount feature
# RUN --mount=type=cache,target=/app/.npm \
# npm install
#
# RUN --mount=type=cache,target=/app/.npm \
# npm install [email protected]
# RUN npm run build
# Build step #1: build the React front end
FROM node:16-alpine as build-step
ARG URL_PREFIX
WORKDIR /app
# If you ran the custom-plotly build from above.
# COPY --from=plotly-step /plotly.js/dist/plotly.min.js ./frontend/custom-plotly.js/plotly.min.js
#
# Otherwise:
COPY ./frontend/custom-plotly.js/plotly.min.js ./frontend/custom-plotly.js/plotly.min.js
ENV PATH /app/node_modules/.bin:$PATH
# RUN date
# RUN apk add -U tzdata
# ENV TZ America/New_York
# RUN date
COPY ./frontend/package.json ./frontend
RUN cd frontend && npm install
COPY ./frontend/custom-plotly.js/package.json ./frontend/custom-plotly.js/
RUN cd frontend && npm install ./custom-plotly.js/
COPY ./frontend/src ./frontend/src
COPY ./frontend/public ./frontend/public
ENV PUBLIC_URL=$URL_PREFIX
RUN cd frontend && npm run build
# Build step #2: build the API with the client as static files
FROM python:3.9
ARG URL_PREFIX
WORKDIR /app
COPY --from=build-step /app/frontend/build ./frontend/build
RUN mkdir ./plotplot
COPY plotplot/requirements.txt ./plotplot/
# Install dependencies using the cache mount feature
RUN pip install -r ./plotplot/requirements.txt
COPY ./plotplot ./plotplot
ENV FLASK_ENV production
ENV PYTHONUNBUFFERED TRUE
# Set the URL prefix, see https://dlukes.github.io/flask-wsgi-url-prefix.html#mwe
ENV SCRIPT_NAME $URL_PREFIX
EXPOSE 9042
WORKDIR /app
CMD ["gunicorn", "-b", ":9042", "-t", "200", "--log-level", "debug", "-w", "1", "--threads", "10", "plotplot.backend:app"]