Newer
Older
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
#
# This is the Project Lynchburg Dockerfile
# It creates a docker container with web2py, uwsgi and tornado
# ready to connect to a reverse proxy on the system.
#
# Exposed are ports 80 and 8888 which requires uwsgi_pass and a reverse
# connection upgrade to websockts proxy_pass respectively
#
# This is a modified Dockerfile originally created by @smithmicro (https://github.com/smithmicro/web2py)
#
# Initial setup
FROM python:alpine
ARG ADMIN_PASSWORD=
RUN [ ! -z "${ADMIN_PASSWORD}" ] || { echo "Please specify an web2py admin password using the 'docker build --build-arg \"ADMIN_PASSWORD=<PASSWORD>\"' build flag"; exit 1; }
ENV WEB2PY_PASSWORD $ADMIN_PASSWORD
ENV WEB2PY_ROOT=/opt/web2py
# This enables logging only for 5xx errors
ENV UWSGI_OPTIONS="--master --thunder-lock --enable-threads --disable-logging --log-5xx"
WORKDIR /opt
# Install necessary packages
RUN apk update && apk add \
build-base \
linux-headers \
pcre-dev \
wget \
nano \
bash \
git \
tzdata
RUN pip install --upgrade pip \
&& pip install uwsgi \
&& pip install tornado
# Download and install the latest web2py
RUN wget http://web2py.com/examples/static/web2py_src.zip \
&& unzip web2py_src.zip \
&& rm web2py_src.zip
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# WORKAROUND:
#
# Replace the web2py "websocket_messaging.py" with a custom one fixed for python3.8
# If at some point this file is fixed for python3.8 in the Git Repo, this can be removed
# (https://github.com/web2py/web2py/blob/master/gluon/contrib/websocket_messaging.py)
#
COPY files/websocket_messaging.py $WEB2PY_ROOT
RUN cp $WEB2PY_ROOT/websocket_messaging.py $WEB2PY_ROOT/gluon/contrib/websocket_messaging.py
#
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
RUN mv $WEB2PY_ROOT/handlers/wsgihandler.py $WEB2PY_ROOT \
&& mv $WEB2PY_ROOT/gluon/contrib/websocket_messaging.py $WEB2PY_ROOT \
&& ln -s $WEB2PY_ROOT/wsgihandler.py $WEB2PY_ROOT/handlers \
&& ln -s $WEB2PY_ROOT/websocket_messaging.py $WEB2PY_ROOT/gluon/contrib/
# Copy meta files
COPY files/entrypoint.sh /usr/local/bin/
COPY files/start_websockets.sh /usr/local/bin/
COPY files/routes.py $WEB2PY_ROOT
RUN chmod +x /usr/local/bin/entrypoint.sh \
&& chmod +x /usr/local/bin/start_websockets.sh
# Clone project files
WORKDIR $WEB2PY_ROOT/applications
RUN git clone https://git.noc.ruhr-uni-bochum.de/lynchburg/lynchburg-server app
# Set reverse proxy flag
WORKDIR $WEB2PY_ROOT/applications/app/private
RUN sed -i -e '/rproxy\s*=/ s/= .*/= true/' ./appconfig.ini
# Generate websocket key from admin pw
WORKDIR $WEB2PY_ROOT
RUN echo "$WEB2PY_PASSWORD" | sha256sum | cut -c1-32 > websocket_key.txt \
&& cat websocket_key.txt
ENTRYPOINT [ "entrypoint.sh" ]
CMD [ "uwsgi" ]
EXPOSE 80 8888