-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
157 lines (120 loc) · 3.98 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# --- TARGET node ---
ARG NODE_VERSION=12.22-dev
ARG PYTHON_VER=3.6
ARG NGINX_VERSION=1.21
FROM wodby/node:${NODE_VERSION} AS node
# copy sources
COPY package.json yarn.lock webpack.config.js ./
COPY --chown=node:node assets ./assets
# install all node packages
RUN npm install
# build reactjs bundle
ARG HOST
ARG WS_HOST
ARG PROTOCOL
ARG WS_PROTOCOL
RUN ./node_modules/.bin/webpack --config webpack.config.js
# --- END TARGET node ---
# --- TARGET build ---
ARG PYTHON_VER
ARG NGINX_VERSION
FROM wodby/python:${PYTHON_VER}-dev AS build
# copy all webpack files
COPY --from=node --chown=wodby:wodby /usr/src/app/assets/bundles ./assets/bundles
COPY --from=node --chown=wodby:wodby /usr/src/app/webpack-stats.json ./
# copy sources
COPY --chown=wodby:wodby ramascene ./ramascene
COPY --chown=wodby:wodby ramasceneMasterProject ./ramasceneMasterProject
COPY --chown=wodby:wodby static_assets ./static_assets
COPY --chown=wodby:wodby templates ./templates
COPY --chown=wodby:wodby .env manage.py requirements.txt rtd_requirements.txt ./
# Install all python packages & clean up
RUN pip install --retries 3 --no-cache-dir --disable-pip-version-check --no-python-version-warning -r requirements.txt
# Install gettext
# USER root
# RUN set -ex; \
# apk add --update --no-cache gettext
# USER wodby
# compile localized strings
# RUN python manage.py compilemessages
# compile all assets
ARG DJANGO_SETTINGS_MODULE
ARG HOST
ARG DATASETS_VERSION
ARG SECRET_KEY
ARG BROKER_URL
ARG PUBLIC_DIR
ARG WS_HOST
ARG PROTOCOL
ARG WS_PROTOCOL
ARG REDIS_HOST
ARG DATABASE_NAME
RUN python manage.py collectstatic
# --- END TARGET build ---
# --- TARGET python ---
ARG PYTHON_VER
ARG NGINX_VERSION
FROM wodby/python:${PYTHON_VER} AS python
ARG DJANGO_SETTINGS_MODULE
ARG HOST
ARG DATASETS_VERSION
ARG SECRET_KEY
ARG BROKER_URL
ARG PUBLIC_DIR
ARG WS_HOST
ARG PROTOCOL
ARG WS_PROTOCOL
ARG REDIS_HOST
ARG DATABASE_NAME
ENV PYTHONUNBUFFERED=1
# create directories
USER root
RUN install -o wodby -g wodby -d ./logs
RUN install -o wodby -g wodby -d /mnt/data
RUN install -o wodby -g wodby -d /mnt/datasets
USER wodby
# Copy all packages
COPY --from=build --chown=wodby:wodby /home/wodby/.local /home/wodby/.local
COPY --from=build --chown=wodby:wodby /usr/src/app/webpack-stats.json ./
# Copy all source files
COPY --chown=wodby:wodby python_ini ./python_ini
COPY --chown=wodby:wodby ramascene ./ramascene
COPY --chown=wodby:wodby ramasceneMasterProject ./ramasceneMasterProject
COPY --chown=wodby:wodby templates ./templates
COPY manage.py .env LICENSE README.md ./
ENV DATABASES_DEFAULT_NAME=/mnt/data/${DATABASE_NAME}
ENV DATASETS_DIR=/mnt/datasets
RUN python manage.py makemigrations
RUN python manage.py migrate
RUN python manage.py populateHierarchies
EXPOSE 8000
CMD ["daphne", "ramasceneMasterProject.asgi:application", "-b", "0.0.0.0", "-p", "8000"]
# --- END TARGET python ---
# --- TARGET reverse proxy ---
ARG NGINX_VERSION
FROM wodby/nginx:${NGINX_VERSION} as nginx
RUN { \
echo "map \$http_upgrade \$connection_upgrade {" ; \
echo " default upgrade;" ; \
echo " '' close;" ; \
echo "}" ; \
echo "include upstream.conf;" ; \
echo "server {" ; \
echo " listen 80 default_server;" ; \
echo " server_name default;" ; \
echo " root /var/www/html;" ; \
echo " include preset.conf;" ; \
echo " location /ws/ {" ; \
echo " proxy_pass http://app_server/;" ; \
echo " proxy_http_version 1.1;" ; \
echo " proxy_set_header Upgrade \$http_upgrade;" ; \
echo " proxy_set_header Connection \$connection_upgrade;" ; \
echo " proxy_set_header Host \$http_host;" ; \
echo " proxy_redirect off;" ; \
echo " }" ; \
echo " include defaults.conf;" ; \
echo "}" ; \
} > /etc/nginx/conf.d/ramascene_vhost.conf;
# Copy all static files
COPY --from=build --chown=wodby:wodby /usr/src/app/public/ /var/www/html/
# --- END TARGET nginx ---