Skip to content

Commit

Permalink
added Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjung committed Jun 14, 2024
1 parent 2c88f27 commit 534d41c
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM debian:latest

RUN apt-get update
RUN apt-get install -y python3 python3-dev python3-pip python3-venv apache2 apache2-dev libapache2-mod-wsgi-py3
RUN apt-get install -y wget ca-certificates make gcc musl-dev

COPY apache2.conf /etc/apache2/
WORKDIR /data/local/app
COPY . /data/local/app

RUN python3 -m venv /data/local/venv
# Enable venv
ENV PATH="/data/local/venv/bin:$PATH"
RUN pip install -U pip setuptools wheel
RUN pip install --no-cache-dir mod_wsgi
RUN pip install -r requirements.txt

RUN mkdir /flask_session
RUN chown www-data /flask_session
RUN chgrp www-data /flask_session

EXPOSE 80

CMD [ "apachectl", "-D", "FOREGROUND" ]
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ pip install -r requirements.txt
Get a copy of local.py from another developer or from one of the production
servers and place it in the mlc directory.

Alternatively, once you get a copy of local.py, you can run the site locally
with mod_wsgi with Docker:
```console
docker build -t <imagename> .
docker run -p 8080:80 -it <imagename>
```

Build a Glottolog lookup and SQLite database for the site.
```console
flask build-glottolog-lookup
Expand Down
89 changes: 89 additions & 0 deletions apache2.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
DefaultRuntimeDir ${APACHE_RUN_DIR}

PidFile ${APACHE_PID_FILE}

Timeout 10

KeepAlive On

MaxKeepAliveRequests 100
WSGIScriptAlias / /data/local/app/app.wsgi
WSGIDaemonProcess app user=www-data group=www-data threads=15 processes=1 python-path=/data/local/venv/lib/python3.11/site-packages:/data/local/app
WSGIProcessGroup app

<Directory /data/local/app>
Require all granted
</Directory>

Alias /css /data/local/app/css
<Location /css>
Require all granted
</Location>

Alias /img /data/local/app/img
<Location /img>
Require all granted
</Location>

Alias /js /data/local/app/js
<Location /js>
Require all granted
</Location>

KeepAliveTimeout 5

# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here. If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog ${APACHE_LOG_DIR}/error.log

#
# LogLevel: Control the severity of messages logged to the error_log.
# Available values: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the log level for particular modules, e.g.
# "LogLevel info ssl:warn"
#
LogLevel warn

# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

# Include list of ports to listen on
Include ports.conf

<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>

<FilesMatch "^\.ht">
Require all denied
</FilesMatch>

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

ServerName localhost

0 comments on commit 534d41c

Please sign in to comment.