-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.static
86 lines (77 loc) · 3.73 KB
/
Dockerfile.static
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
82
83
84
85
86
ARG VERSION
ARG ARCHES_PROJECT=scarlet
ARG ARCHES_BASE=flaxandteal/arches_base
ARG ARCHES_DYNAMIC_IMAGE=flaxandteal_${ARCHES_PROJECT}:$VERSION
ARG WEB_ROOT=/web_root
ARG ARCHES_ENVIRONMENT=production
FROM $ARCHES_DYNAMIC_IMAGE as arches
USER 0
ARG DJANGO_DUMMY_SECRET_KEY
ARG STATIC_URL=/static/
ARG ARCHES_PROJECT
ARG ARCHES_DYNAMIC_IMAGE
ARG ARCHES_NAMESPACE_FOR_DATA_EXPORT
ARG PUBLIC_SERVER_ADDRESS
ARG ARCHES_ENVIRONMENT
ENV DJANGO_DEBUG=False \
DJANGO_MODE=STATIC \
STATIC_URL=${STATIC_URL} \
STATIC_ROOT=/static_root \
ARCHES_NAMESPACE_FOR_DATA_EXPORT=${ARCHES_NAMESPACE_FOR_DATA_EXPORT} \
PUBLIC_SERVER_ADDRESS=${PUBLIC_SERVER_ADDRESS} \
ARCHES_PROJECT=${ARCHES_PROJECT} \
ARCHES_ENVIRONMENT=${ARCHES_ENVIRONMENT} \
PROJECT_ROOT=${WEB_ROOT}/${ARCHES_PROJECT}/${ARCHES_PROJECT} \
DJANGO_SECRET_KEY=${DJANGO_DUMMY_SECRET_KEY} \
COMPRESS_OFFLINE=True \
COMPRESS_ENABLED=True \
PGUSERNAME=postgres \
PGPASSWORD=postgres \
PGDBNAME=arches \
PGHOST=localhost \
PGPORT=5432 \
RABBITMQ_USER=rabbitmq \
RABBITMQ_PASS=rabbitmq \
CANTALOUPE_HOST=cantaloupe \
CANTALOUPE_PORT=8182 \
COUCHDB_HOST=couchdb \
COUCHDB_PORT=5984 \
COUCHDB_USER=admin \
COUCHDB_PASS=password \
ESHOST=localhost \
ESPORT=9200 \
CELERY_BROKER_URL=amqp://rabbitmq \
DOMAIN_NAMES=localhost \
PYTHONUNBUFFERED=0 \
TZ=PST \
DJANGO_SETTINGS_MODULE=${ARCHES_PROJECT}.settings
WORKDIR ${WEB_ROOT}/${ARCHES_PROJECT}
RUN ${WEB_ROOT}/entrypoint.sh init_yarn_components
# FIXME: To be replaced once per-project settings working
RUN (echo "\nSTATIC_ROOT='${STATIC_ROOT}'" >> ${WEB_ROOT}/${ARCHES_PROJECT}/${ARCHES_PROJECT}/settings_local.py) && echo $STATIC_ROOT
RUN (echo "\nARCHES_NAMESPACE_FOR_DATA_EXPORT='${ARCHES_NAMESPACE_FOR_DATA_EXPORT}'" >> ${WEB_ROOT}/${ARCHES_PROJECT}/${ARCHES_PROJECT}/settings_local.py) && echo $STATIC_ROOT
RUN (echo "\nPUBLIC_SERVER_ADDRESS='${PUBLIC_SERVER_ADDRESS}' or ARCHES_NAMESPACE_FOR_DATA_EXPORT" >> ${WEB_ROOT}/${ARCHES_PROJECT}/${ARCHES_PROJECT}/settings_local.py) && echo $STATIC_ROOT
RUN (cd $WEB_ROOT/arches/arches && NODE_OPTIONS=--max_old_space_size=8192 NODE_PATH=$WEB_ROOT/$ARCHES_PROJECT/$ARCHES_PROJECT/media/node_modules yarn install)
RUN (cd $WEB_ROOT/$ARCHES_PROJECT/$ARCHES_PROJECT && NODE_OPTIONS=--max_old_space_size=8192 NODE_PATH=./media/node_modules yarn install -D)
RUN apt-get update && apt-get -y install python3-libxml2 git
RUN /bin/bash -c ". ../ENV/bin/activate;\
python manage.py createcachetable;\
python manage.py load_ontology -s ${ARCHES_PROJECT}/pkg/ontologies;\
python manage.py packages -o load_package -s ${ARCHES_PROJECT}/pkg/ -y --no-business_data;\
python manage.py es index_database\
";
COPY ./${ARCHES_PROJECT}/settings.py ${WEB_ROOT}/${ARCHES_PROJECT}/${ARCHES_PROJECT}/settings.py
RUN echo $WEB_ROOT "|" $ARCHES_PROJECT && ${WEB_ROOT}/entrypoint.sh run_arches
RUN echo $WEB_ROOT "|" $ARCHES_PROJECT && ${WEB_ROOT}/entrypoint.sh run_yarn_build_${ARCHES_ENVIRONMENT}
FROM nginxinc/nginx-unprivileged:1.21.5-alpine
ARG WEB_ROOT=/web_root
ARG STATIC_ROOT=/static_root
ARG ARCHES_PROJECT
COPY --from=arches ${WEB_ROOT}/${ARCHES_PROJECT}/${ARCHES_PROJECT}/media/* /usr/share/nginx/html/
COPY --from=arches ${WEB_ROOT}/${ARCHES_PROJECT}/${ARCHES_PROJECT}/media/build/js/* /usr/share/nginx/html/js/
COPY --from=arches ${WEB_ROOT}/${ARCHES_PROJECT}/${ARCHES_PROJECT}/webpack/webpack-stats.json /usr/share/nginx/webpack-stats.json
COPY --from=arches ${WEB_ROOT}/${ARCHES_PROJECT}/${ARCHES_PROJECT}/media/node_modules/js-cookie/src/js.cookie.js /usr/share/nginx/html/js/js-cookie.js
COPY --from=arches ${STATIC_ROOT} /usr/share/nginx/html/static
#RUN mv /usr/share/nginx/html/static/* /usr/share/nginx/html
# Must be numeric to verify not root
USER 33