-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathheroku.dockerfile
80 lines (64 loc) · 2.54 KB
/
heroku.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
77
78
79
80
# # # # # # # # # # # # # # # # # # # # # # # #
# frontend
# # # # # # # # # # # # # # # # # # # # # # # #
FROM node:12.19.0-alpine AS frontend-build
RUN yarn global add @vue/[email protected]
WORKDIR /app
COPY ./frontend/package.json ./frontend/yarn.lock ./
RUN yarn install
COPY ./frontend .
# TODO: Restore via https://github.com/scaife-viewer/beyond-translation-site/issues/135
# ENV VUE_APP_ABOUT_URL="https://sites.tufts.edu/perseusupdates/2023/03/15/perseus-6-0-beyond-translation-the-first-version-of-a-next-generation-perseus/"
RUN yarn build
# # # # # # # # # # # # # # # # # # # # # # # #
# backend
# # # # # # # # # # # # # # # # # # # # # # # #
FROM python:3.9 AS backend-build
WORKDIR /opt/scaife-stack/src/
RUN pip install --disable-pip-version-check --upgrade pip setuptools wheel virtualenv
ENV PATH="/opt/scaife-stack/bin:${PATH}" VIRTUAL_ENV="/opt/scaife-stack"
COPY ./backend/requirements.txt /opt/scaife-stack/src/
RUN set -x \
&& virtualenv /opt/scaife-stack \
&& pip install -r requirements.txt
# # # # # # # # # # # # # # # # # # # # # # # #
# backend data and code prep
# # # # # # # # # # # # # # # # # # # # # # # #
FROM backend-build as backend-prep
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONPATH=/opt/scaife-stack/src/ \
PATH="/opt/scaife-stack/bin:${PATH}" \
VIRTUAL_ENV="/opt/scaife-stack" \
DB_DATA_PATH="/opt/scaife-stack/db-data"
WORKDIR /opt/scaife-stack/src/
COPY ./backend .
ARG HEROKU_APP_NAME
ARG ATLAS_DB_URL
RUN sh scripts/prepare-atlas-data.sh ${ATLAS_DB_URL}
RUN python manage.py loaddata fixtures/sites.json
# TODO: Revisit this if we tweak this multistage file
# to handle code / data changes out of band
# TODO: tocs not there; what to do?
RUN rm -Rf data
# TODO: Ensure $HEROKU_APP_NAME is applied via
# an entrypoint script
# RUN python manage.py update_site_for_review_app
# # # # # # # # # # # # # # # # # # # # # # # #
# webapp
# # # # # # # # # # # # # # # # # # # # # # # #
FROM backend-build as webapp
WORKDIR /opt/scaife-stack/src/
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONPATH=/opt/scaife-stack/src/ \
PATH="/opt/scaife-stack/bin:${PATH}" \
VIRTUAL_ENV="/opt/scaife-stack" \
DB_DATA_PATH="/opt/scaife-stack/db-data" \
PORT=8000
COPY --from=frontend-build /app/dist /opt/scaife-stack/src/static
# TODO: we may be able to tweak this COPY directive slightly
COPY --from=backend-prep /opt/scaife-stack /opt/scaife-stack
COPY ./backend/data/tocs /opt/scaife-stack/src/data/tocs
RUN python manage.py collectstatic
CMD gunicorn scaife_stack_atlas.wsgi