-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
81 lines (66 loc) · 2.45 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
77
78
79
80
81
# Add all the dependencies
FROM python:3.11-alpine as base
# Add requirements and install dependencies
WORKDIR /app/
ADD requirements.txt /app/
ADD requirements-prod.txt /app/
# Add dependencies
RUN mkdir -p /var/www/api/admin/static/ \
&& apk add --no-cache bash postgresql-libs postgresql-client pcre-dev libffi-dev mailcap supervisor yarn \
&& apk add --no-cache --virtual .build-deps gcc g++ musl-dev postgresql-dev linux-headers python3-dev \
&& pip install -r requirements.txt -r requirements-prod.txt --no-cache-dir \
&& apk --purge del .build-deps
FROM base as frontend
# add and run the frontend code
ADD frontend /app/frontend
WORKDIR /app/frontend
ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_ENV=production
RUN yarn install --frozen-lockfile --production
RUN yarn build --no-lint
FROM base as final
ARG DJANGO_SECRET_KEY=something-insecure
ARG DJANGO_DB_ENGINE "django.db.backends.sqlite3"
ARG DJANGO_DB_NAME "/data/mhd.db"
ARG DJANGO_DB_USER ""
ARG DJANGO_DB_PASSWORD ""
ARG DJANGO_DB_HOST ""
ARG DJANGO_DB_PORT ""
# Install Django App, configure settings and copy over djano app
ADD manage.py /app/
ADD mhd/ /app/mhd/
ADD mhd_data/ /app/mhd_data/
ADD mhd_provenance/ /app/mhd_provenance/
ADD mhd_schema/ /app/mhd_schema/
ADD mhd_tests/ /app/mhd_tests/
ADD mddl_catalog/ /app/mddl_catalog/
ADD mviews/ /app/mviews/
### ALL THE CONFIGURATION
ENV DJANGO_SETTINGS_MODULE "mhd.docker_settings"
ENV DJANGO_SECRET_KEY $DJANGO_SECRET_KEY
ENV DJANGO_DB_ENGINE $DJANGO_DB_ENGINE
ENV DJANGO_DB_NAME $DJANGO_DB_NAME
ENV DJANGO_DB_USER $DJANGO_DB_USER
ENV DJANGO_DB_PASSWORD $DJANGO_DB_PASSWORD
ENV DJANGO_DB_HOST $DJANGO_DB_HOST
ENV DJANGO_DB_PORT $DJANGO_DB_PORT
# Copy over static files
RUN DJANGO_SECRET_KEY=setup python manage.py collectstatic --noinput
WORKDIR /app/frontend/
COPY --from=frontend /app/frontend/content ./content
COPY --from=frontend /app/frontend/public ./public
COPY --from=frontend /app/frontend/package.json ./package.json
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=frontend /app/frontend/.next/standalone ./
COPY --from=frontend /app/frontend/.next/static ./.next/static
# Add uwsgi, supervisor config and entrypoint
ADD docker/entrypoint.sh /entrypoint.sh
ADD docker/supervisor.conf /supervisor.conf
ADD docker/uwsgi.ini /uwsgi.ini
# Volume and ports
VOLUME /data/
EXPOSE 80
WORKDIR /app/
ENTRYPOINT ["/entrypoint.sh"]
CMD ["supervisord", "-c", "/supervisor.conf"]