Skip to content

Commit

Permalink
Add Docker production config RockefellerArchiveCenter#175
Browse files Browse the repository at this point in the history
  • Loading branch information
kcloud committed Feb 24, 2023
1 parent da759ec commit 02177ec
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM python:3.10

ENV PYTHONUNBUFFERED 1
ARG SCORPIO_DNS
ARG APPLICATION_PORT
RUN apt-get update
RUN apt-get install --yes apache2 apache2-dev
RUN apt-get install --yes postgresql
RUN apt-get -y install python3-pip
RUN pip install --upgrade pip

RUN wget https://github.com/GrahamDumpleton/mod_wsgi/archive/refs/tags/4.9.0.tar.gz \
&& tar xvfz 4.9.0.tar.gz \
&& cd mod_wsgi-4.9.0 \
&& ./configure --with-apxs=/usr/bin/apxs --with-python=/usr/local/bin/python \
&& make \
&& make install \
&& make clean

ADD ./apache/000-scorpio.conf /etc/apache2/sites-available/000-scorpio.conf
RUN sed "s/ENV_SCORPIO_DNS/${SCORPIO_DNS}/" -i /etc/apache2/sites-available/000-scorpio.conf
RUN sed "s/ENV_SCORPIO_PORT/${APPLICATION_PORT}/" -i /etc/apache2/sites-available/000-scorpio.conf
ADD ./apache/wsgi.load /etc/apache2/mods-available/wsgi.load
RUN a2dissite 000-default
RUN a2ensite 000-scorpio.conf
RUN a2enmod headers
RUN a2enmod rewrite
RUN a2enmod wsgi

COPY . /var/www/scorpio
WORKDIR /var/www/scorpio
RUN pip install -r requirements.txt
RUN ./manage.py collectstatic

EXPOSE ${APPLICATION_PORT}
CMD ["apache2ctl", "-D", "FOREGROUND"]
20 changes: 20 additions & 0 deletions apache/000-scorpio.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Listen ENV_SCORPIO_PORT
<VirtualHost *:ENV_SCORPIO_PORT>
ErrorLog /var/log/apache2/scorpio_error_log
CustomLog /var/log/apache2/scorpio_access_log combined
ServerName ENV_SCORPIO_DNS
DocumentRoot /var/www/html
Alias /static /var/www/scorpio/static
<Directory /var/www/scorpio/static>
Options Includes FollowSymLinks MultiViews
Require all granted
</Directory>
<Directory /var/www/scorpio/scorpio>
WSGIProcessGroup scorpio
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
WSGIDaemonProcess scorpio home=/var/www/scorpio
WSGIProcessGroup scorpio
WSGIScriptAlias / /var/www/scorpio/scorpio/wsgi.py
</VirtualHost>
1 change: 1 addition & 0 deletions apache/wsgi.load
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
7 changes: 7 additions & 0 deletions cron/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

env >> environment

# execute CMD
echo "$@"
exec "$@"
7 changes: 7 additions & 0 deletions cron/scorpio_cron
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#Don't remove empty line at end of file. It is required for cron to run.
SCORPIO_ROOT=/code/scorpio
00,30 * * * * $SCORPIO_ROOT/python -u /code/manage.py runcrons "indexer.cron.IndexAgents" >> /var/log/scorpio-cron/scorpio-agents.txt 2>&1
10,40 * * * * $SCORPIO_ROOT/python -u /code/manage.py runcrons "indexer.cron.IndexCollections" >> /var/log/scorpio-cron/scorpio-collections.txt 2>&1
20,50 * * * * $SCORPIO_ROOT/python -u /code/manage.py runcrons "indexer.cron.IndexObjects" >> /var/log/scorpio-cron/scorpio-objects.txt 2>&1
5 0,12 * * * $SCORPIO_ROOT/python -u /code/manage.py runcrons "indexer.cron.CleanUpCompleted" >> /var/log/scorpio-cron/scorpio-cleanupcompleted.txt 2>&1

0 comments on commit 02177ec

Please sign in to comment.