-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
91 lines (77 loc) · 2.4 KB
/
Dockerfile
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# syntax=docker/dockerfile:1.6
############################################################
# Dockerfile for running agilecards wsgi app
############################################################
# Set the base image
FROM ubuntu:jammy
# Arguments - change as needed
ARG HOSTNAME=agilecards.example.com
ARG WEBMASTER=webmaster@localhost
ARG PORT=80
ARG IMAGESOURCE="static/"
# File Author / Maintainer
LABEL name="agilecards"
LABEL url="https://github.com/PhilSwiss/agile-cards"
LABEL description="Agile Cards WSGI App"
LABEL version="1.0"
# Arguments - do not change these
ARG DEBIAN_FRONTEND=noninteractive
# Write files
COPY <<EOF /tmp/agilecards.conf
<VirtualHost *:${PORT}>
ServerName ${HOSTNAME}
ServerAdmin ${WEBMASTER}
DocumentRoot "/var/www"
RedirectMatch ^/$ /agilecards/
<Directory "/var/www">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/agilecards_error.log
CustomLog ${APACHE_LOG_DIR}/agilecards_access.log combined
WSGIDaemonProcess agilecards threads=2
WSGIScriptAlias /agilecards /var/www/agilecards/agilecards.wsgi
<Directory /var/www/agilecards>
WSGIProcessGroup agilecards
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
EOF
# Install Software needed to run this service
RUN <<EOF
apt update
apt-get -y upgrade
apt-get -y autoremove
apt install -y python3 python3-flask apache2 libapache2-mod-wsgi-py3
EOF
# Prepare directory structure
RUN <<EOF
mkdir -p /var/www/agilecards
mkdir -p /var/www/agilecards/static
mkdir -p /var/www/agilecards/templates
EOF
# Copy App & Images, remove unneeded files
COPY agilecards.py /var/www/agilecards
COPY agilecards.wsgi /var/www/agilecards
COPY agilecards.cfg /var/www/agilecards
COPY templates/ /var/www/agilecards/templates
COPY ${IMAGESOURCE} /var/www/agilecards/static
RUN rm /var/www/agilecards/static/examplecard1.jpg || true
RUN rm /var/www/agilecards/static/examplecard2.jpeg || true
RUN rm /var/www/agilecards/static/examplecard3.gif || true
# Configure Apache
RUN <<EOF
chown -R www-data:www-data /var/www/agilecards
cp /tmp/agilecards.conf /etc/apache2/sites-available/
a2dissite 000-default.conf
a2ensite agilecards.conf
a2enmod wsgi
a2enmod rewrite
EOF
# Expose port and start Apache
EXPOSE ${PORT}
WORKDIR /var/www/agilecards
CMD /usr/sbin/apache2ctl -D FOREGROUND