Unverified Commit b0966fab authored by olaf michaelis's avatar olaf michaelis Committed by GitHub
Browse files

Merge pull request #10 from rdmorganiser/configurable_base_url

Configurable base url
parents 94c50466 6941be52
...@@ -3,6 +3,7 @@ FROM httpd:latest ...@@ -3,6 +3,7 @@ FROM httpd:latest
ARG UID=<UID> ARG UID=<UID>
ENV HTTPD_CONF="/usr/local/apache2/conf/httpd.conf" 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 \ RUN apt update -y && apt install -y \
curl \ curl \
...@@ -21,11 +22,16 @@ RUN echo "LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so" >> ${HTTP ...@@ -21,11 +22,16 @@ RUN echo "LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so" >> ${HTTP
&& echo "IncludeOptional conf.d/*.conf" >> ${HTTPD_CONF} && echo "IncludeOptional conf.d/*.conf" >> ${HTTPD_CONF}
RUN mkdir -p /usr/local/apache2/conf.d RUN mkdir -p /usr/local/apache2/conf.d
COPY vhosts.conf /usr/local/apache2/conf.d/vhosts.conf 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 useradd -m -u $UID -s /bin/bash rdmo
RUN mkdir -p /var/www/html RUN mkdir -p /var/www/html
RUN mkdir -p /var/run/apache2 RUN mkdir -p /var/run/apache2
HEALTHCHECK --timeout=10s --interval=20s --retries=3 \ HEALTHCHECK --timeout=10s --interval=20s --retries=3 \
CMD curl -f http://localhost:80 || exit 1 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
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
DocumentRoot /var/www/html/ DocumentRoot /var/www/html/
Alias /static /vol/rdmo-app/static_root/ Alias ${BASE_STATIC} /vol/rdmo-app/static_root/
<Directory /vol/rdmo-app/static_root/> <Directory /vol/rdmo-app/static_root>
Require all granted Require all granted
</Directory> </Directory>
...@@ -11,10 +11,10 @@ ...@@ -11,10 +11,10 @@
python-path=/vol/rdmo-app python-home=/vol/ve python-path=/vol/rdmo-app python-home=/vol/ve
WSGIProcessGroup rdmo WSGIProcessGroup rdmo
WSGIScriptAlias / /vol/rdmo-app/config/wsgi.py process-group=rdmo WSGIScriptAlias ${BASE_URL} /vol/rdmo-app/config/wsgi.py process-group=rdmo
WSGIPassAuthorization On WSGIPassAuthorization On
<Directory /vol/rdmo-app/config/> <Directory /vol/rdmo-app/config>
<Files wsgi.py> <Files wsgi.py>
Require all granted Require all granted
</Files> </Files>
......
...@@ -4,7 +4,6 @@ source /opt/ve.sh ...@@ -4,7 +4,6 @@ source /opt/ve.sh
if [[ $(pip freeze | grep -Poc "^rdmo==") == "0" ]]; then if [[ $(pip freeze | grep -Poc "^rdmo==") == "0" ]]; then
cp -f /tmp/wsgi.py /vol/rdmo-app/config/wsgi.py
pip install --upgrade pip pip install --upgrade pip
pip install --upgrade wheel pip install --upgrade wheel
...@@ -15,6 +14,7 @@ if [[ $(pip freeze | grep -Poc "^rdmo==") == "0" ]]; then ...@@ -15,6 +14,7 @@ if [[ $(pip freeze | grep -Poc "^rdmo==") == "0" ]]; then
git clone ${RDMO_APP_REPO} ${RDMO_APP} git clone ${RDMO_APP_REPO} ${RDMO_APP}
cp -f /tmp/template_local.py ${RDMO_APP}/config/settings/local.py cp -f /tmp/template_local.py ${RDMO_APP}/config/settings/local.py
cp -f /tmp/wsgi.py ${RDMO_APP}/config/wsgi.py
cd ${RDMO_APP} cd ${RDMO_APP}
python manage.py makemigrations python manage.py makemigrations
......
...@@ -17,7 +17,7 @@ cryptographic signing, and should be set to a unique, unpredictable value. ...@@ -17,7 +17,7 @@ cryptographic signing, and should be set to a unique, unpredictable value.
SECRET_KEY = 'this is not a very secret key' SECRET_KEY = 'this is not a very secret key'
''' '''
The list of URLs und which this application available The list of URLs under which this application is available
''' '''
ALLOWED_HOSTS = [x.strip() for x in os.environ['ALLOWED_HOSTS'].split(',')] ALLOWED_HOSTS = [x.strip() for x in os.environ['ALLOWED_HOSTS'].split(',')]
# ALLOWED_HOSTS = ['localhost', 'ip6-localhost', '127.0.0.1', '[::1]', 'rdmo'] # ALLOWED_HOSTS = ['localhost', 'ip6-localhost', '127.0.0.1', '[::1]', 'rdmo']
...@@ -25,7 +25,10 @@ ALLOWED_HOSTS = [x.strip() for x in os.environ['ALLOWED_HOSTS'].split(',')] ...@@ -25,7 +25,10 @@ ALLOWED_HOSTS = [x.strip() for x in os.environ['ALLOWED_HOSTS'].split(',')]
''' '''
The root url of your application, only needed when its not '/' The root url of your application, only needed when its not '/'
''' '''
# BASE_URL = '/path' try:
BASE_URL = os.environ['BASE_URL']
except KeyError:
BASE_URL = ''
''' '''
Language code and time zone Language code and time zone
......
...@@ -2,6 +2,6 @@ import os ...@@ -2,6 +2,6 @@ import os
from django.core.wsgi import get_wsgi_application from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
application = get_wsgi_application() application = get_wsgi_application()
# these are to modify the docker-compose.yaml # these are to modify the docker-compose.yaml
GLOBAL_PREFIX=rdc- GLOBAL_PREFIX=rdc-
FINALLY_EXPOSED_PORT=8484 FINALLY_EXPOSED_PORT=8484
# Docker restart policy (no, on-failure, always, unless-stopped) # Docker restart policy (no, on-failure, always, unless-stopped)
# see https://docs.docker.com/compose/compose-file/#restart # see https://docs.docker.com/compose/compose-file/#restart
RESTART_POLICY=always RESTART_POLICY=always
# settings inside the containers # necessary for running RDMO under a subpath
VOL=/vol # by default rdmo is available under the root url
# i.e. for 'http://yourrdmo.com/rdmo' set the key to '/rdmo'
BASE_URL=/
# 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
POSTGRES_USER=rdmo POSTGRES_USER=rdmo
...@@ -22,5 +26,7 @@ RDMO_CATALOG=/tmp/rdmo-catalog ...@@ -22,5 +26,7 @@ RDMO_CATALOG=/tmp/rdmo-catalog
RDMO_CATALOG_REPO=https://github.com/rdmorganiser/rdmo-catalog RDMO_CATALOG_REPO=https://github.com/rdmorganiser/rdmo-catalog
DEFAULT_URI_PREFIX=https://rdc/test DEFAULT_URI_PREFIX=https://rdc/test
VOL=/vol
LOGGING_DIR=/vol/log LOGGING_DIR=/vol/log
VE=/vol/ve VE=/vol/ve
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