Commit 3d64b4ec authored by Olaf Michaelis's avatar Olaf Michaelis
Browse files

Remove apache in favour of nginx

parent 1af007ec
vol/
docker-compose.yaml
variables.local
apache/dockerfile
rdmo/dockerfile
\ No newline at end of file
nginx/dockerfile
rdmo/dockerfile
FROM httpd:latest
ARG UID=<UID>
ENV HTTPD_CONF="/usr/local/apache2/conf/httpd.conf"
ENV HTTPD_VHOSTS="/usr/local/apache2/conf.d/vhosts.conf"
RUN apt update -y && apt install -y \
curl \
python-psycopg2 \
libexpat1 \
apache2-utils \
ssl-cert \
python3 \
python3-dev \
python3-pip \
libapache2-mod-wsgi-py3 \
pandoc \
texlive-xetex
RUN echo "LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so" >> ${HTTPD_CONF} \
&& echo "IncludeOptional conf.d/*.conf" >> ${HTTPD_CONF}
RUN mkdir -p /usr/local/apache2/conf.d
COPY ./vhosts.conf "${HTTPD_VHOSTS}"
COPY ./drun.sh /drun.sh
COPY ./healthcheck.sh /healthcheck.sh
RUN useradd -m -u ${UID} -s /bin/bash rdmo
RUN mkdir -p /var/www/html
RUN mkdir -p /var/run/apache2
HEALTHCHECK --timeout=10s --interval=20s --retries=3 \
CMD /healthcheck.sh
CMD ["/drun.sh"]
#!/bin/bash
function sanitize(){
r="$(echo "/${1}/" \
| tr -s "/" \
| sed 's/.$//'
)"
if [[ -z "${r}" ]]; then
echo "/"
else
echo "${r}"
fi
}
export BASE_STATIC=$(sanitize "${BASE_URL}/static")
export BASE_URL=$(sanitize "${BASE_URL}")
# apache gets grumpy about pre-existing pid files
rm -f /usr/local/apache2/logs/httpd.pid
httpd -DFOREGROUND
#!/bin/bash
curl -f http://localhost:80${BASE_URL} || exit 1
<VirtualHost *:80>
DocumentRoot /var/www/html/
Alias ${BASE_STATIC} /vol/rdmo-app/static_root/
<Directory /vol/rdmo-app/static_root>
Require all granted
</Directory>
WSGIDaemonProcess rdmo user=rdmo group=rdmo processes=2 \
python-path=/vol/rdmo-app python-home=/vol/ve
WSGIProcessGroup rdmo
WSGIScriptAlias ${BASE_URL} /vol/rdmo-app/config/wsgi.py process-group=rdmo
WSGIPassAuthorization On
<Directory /vol/rdmo-app/config>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
version: "3.7"
volumes:
log:
name: <GLOBAL_PREFIX>log
driver_opts:
type: none
device: <CURDIR>/vol/log
o: bind
postgres:
name: <GLOBAL_PREFIX>postgres
driver_opts:
type: none
device: <CURDIR>/vol/postgres
o: bind
rdmoapp:
name: <GLOBAL_PREFIX>rdmoapp
driver_opts:
type: none
device: <CURDIR>/vol/rdmo-app
o: bind
ve:
name: <GLOBAL_PREFIX>ve
driver_opts:
type: none
device: <CURDIR>/vol/ve
o: bind
services:
apache:
nginx:
build:
context: ./apache
container_name: <GLOBAL_PREFIX>apache
context: ./nginx
container_name: <GLOBAL_PREFIX>nginx
restart: "<RESTART_POLICY>"
ports:
- "<FINALLY_EXPOSED_PORT>:80"
- "<FINALLY_EXPOSED_PORT>:8080"
volumes:
- log:/vol/log
- rdmoapp:/vol/rdmo-app
......@@ -66,3 +40,29 @@ services:
- ve:/vol/ve
env_file:
- <VARIABLES_FILE>
volumes:
log:
name: <GLOBAL_PREFIX>log
driver_opts:
type: none
device: <CURDIR>/vol/log
o: bind
postgres:
name: <GLOBAL_PREFIX>postgres
driver_opts:
type: none
device: <CURDIR>/vol/postgres
o: bind
rdmoapp:
name: <GLOBAL_PREFIX>rdmoapp
driver_opts:
type: none
device: <CURDIR>/vol/rdmo-app
o: bind
ve:
name: <GLOBAL_PREFIX>ve
driver_opts:
type: none
device: <CURDIR>/vol/ve
o: bind
......@@ -44,14 +44,14 @@ preparations:
| sed 's|<VARIABLES_FILE>|${VARS_ENV}|g' \
> ${DC_TEMP}
cat nginx/dockerfile_master \
| sed 's|<UID>|$(MYID)|g' \
> nginx/dockerfile
cat rdmo/dockerfile_master \
| sed 's|<UID>|$(MYID)|g' \
> rdmo/dockerfile
cat apache/dockerfile_master \
| sed 's|<UID>|$(MYID)|g' \
> apache/dockerfile
run_build:
$(DC_CMD) up --build -d
......
FROM debian:10
ARG UID=<UID>
ENV USER=nginx
RUN apt update -y && apt install -y \
nginx \
curl
RUN rm -rf /etc/nginx/sites-enabled
COPY ./rootfs /
RUN useradd -m -u ${UID} -s /bin/bash "${USER}"
CMD ["/drun.sh"]
#!/bin/bash
nginx
# nginx -c /etc/nginx/nginx.conf
sleep 99d
daemon off;
user nginx;
worker_processes 1;
pid /var/run/nginx.pid;
error_log /vol/log/nginx-error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
sendfile on;
include /etc/nginx/sites-enabled/*.conf;
}
server {
listen 8080;
listen [::]:8080;
server_name rdmo;
location / {
access_log /vol/log/nginx-access.log;
error_log /vol/log/nginx-error.log;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_pass http://rdmo:8080/;
}
location /static/ {
alias /vol/rdmo-app/static_root/;
}
}
FROM debian:latest
FROM debian:10
ARG UID=<UID>
ENV USER=rdmo
ENV PATH=/opt:${PATH}
......@@ -29,10 +30,10 @@ RUN apt install -y \
python-psycopg2
COPY ./rootfs /
RUN chmod -R 777 /tmp
RUN useradd -m -u ${UID} -s /bin/bash rdmo
USER rdmo
RUN useradd -m -u ${UID} -s /bin/bash "${USER}"
RUN chown "${USER}:${USER}" "/home/${USER}"
USER "${USER}"
CMD ["/drun.sh"]
......@@ -28,7 +28,7 @@ The root url of your application, only needed when its not '/'
try:
BASE_URL = os.environ['BASE_URL']
except KeyError:
BASE_URL = ''
pass
'''
Language code and time zone
......
#!/bin/bash
/opt/install-rdmo.sh
source /opt/ve.sh
while true; do
sleep 3600
done
if [[ $(pip freeze | grep -Poc "^rdmo==") == "0" ]]; then
/opt/install-rdmo.sh
else
echo "Won't do anything because RDMO is already installed."
fi
echo "Run gunicorn"
cd "${RDMO_APP}"
gunicorn \
--bind 0.0.0.0:8080 \
--log-level info \
--access-logfile "/vol/log/gunicorn-access.log" \
--error-logfile "/vol/log/gunicorn-error.log" \
config.wsgi:application
......@@ -3,24 +3,20 @@
source /opt/ve.sh
if [[ $(pip freeze | grep -Poc "^rdmo==") == "0" ]]; then
pip install --upgrade pip
pip install --upgrade wheel
pip install --upgrade setuptools
pip install psycopg2
pip install --upgrade pip
pip install --upgrade wheel
pip install --upgrade setuptools
pip install psycopg2
pip install rdmo
pip install rdmo
git clone ${RDMO_APP_REPO} ${RDMO_APP}
cp -f /conf/template_local.py ${RDMO_APP}/config/settings/local.py
git clone ${RDMO_APP_REPO} ${RDMO_APP}
cp -f /tmp/template_local.py ${RDMO_APP}/config/settings/local.py
cp -f /tmp/wsgi.py ${RDMO_APP}/config/wsgi.py
pip install -r ${RDMO_APP}/requirements/gunicorn.txt
cd ${RDMO_APP}
python manage.py makemigrations
python manage.py migrate
python manage.py download_vendor_files
python manage.py collectstatic --no-input
else
echo "Won't do anything because RDMO is already installed."
fi
cd ${RDMO_APP}
python manage.py makemigrations
python manage.py migrate
python manage.py download_vendor_files
python manage.py collectstatic --no-input
#!/bin/bash
if [[ ! -f "${VE}/bin/activate" ]]; then
cd ${VOL}
virtualenv ve
......
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
application = get_wsgi_application()
......@@ -6,13 +6,14 @@ FINALLY_EXPOSED_PORT=8484
# see https://docs.docker.com/compose/compose-file/#restart
RESTART_POLICY=always
# necessary for running RDMO under a subpath
# NOTE: BASE_URL does not work, will be fixed later
# by default rdmo is available under the root url
# if you want to run under a subpath set BASE_URL
# i.e. for 'http://yourrdmo.com/rdmo' set the key to '/rdmo'
BASE_URL=/
# BASE_URL=/rdmo
# the list of URLs under which this application is available
ALLOWED_HOSTS=localhost, ip6-localhost, 127.0.0.1, [::1], rdmo
ALLOWED_HOSTS=localhost, ip6-localhost, 127.0.0.1, [::1], rdmo, rdc-rdmo
POSTGRES_USER=rdmo
POSTGRES_PASSWORD=rdmoPGpass19
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment