From 97a6a80aed364400c2a838d53c3fecc9944821a0 Mon Sep 17 00:00:00 2001
From: hankhill19580 <hankhill19580@gmail.com>
Date: Wed, 23 Sep 2020 14:44:05 +0000
Subject: [PATCH] Enable the use of Docker+Apache2 to host the site, HTTP only.
 HTTPS sites should use a reverse proxy

---
 Dockerfile             | 37 +++++++++++++++++++++++++++++++++++++
 README.md              |  2 +-
 etc/apache2.i2p.conf   | 18 ++++++++++++++++++
 site-updater-docker.sh |  7 +++++++
 4 files changed, 63 insertions(+), 1 deletion(-)
 create mode 100644 Dockerfile
 create mode 100644 etc/apache2.i2p.conf
 create mode 100755 site-updater-docker.sh

diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 000000000..06c2d5eec
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,37 @@
+FROM debian:stable
+ENV SERVERNAME=geti2p.net
+ENV SERVERMAIL=example@geti2p.net
+
+ADD . /var/www/i2p.www
+
+WORKDIR /var/www/i2p.www
+
+    ## Install the dependencies
+RUN apt-get update && \
+    apt-get -y install apache2 apache2-utils libapache2-mod-wsgi python2-dev python-pip patch python-virtualenv git && \
+    ## Start setting up the site
+    virtualenv --distribute env                && \  
+    . env/bin/activate                          && \
+    pip install -r etc/reqs.txt                 && \
+    patch -p0 -N -r - <etc/multi-domain.patch   && \
+    ./compile-messages.sh                       && \  
+    echo "Git revision: $(git log -n 1 | grep commit | sed 's/commit //' | sed 's/ .*$//')" | tee ./i2p2www/pages/include/mtnversion && \
+    ## We've now updated the site
+    ## Next let's configure WSGI
+    ## Set ownership of site to server
+    cp etc/docker.i2p.wsgi i2p.wsgi && \
+    chown -R www-data /var/www/i2p.www                    && \ 
+    ## Make the WSGI script owned by the server 
+    chown www-data:www-data /var/www/i2p.www/i2p.wsgi     && \  
+    ## Make the WSGI script executable
+    chmod 755 /var/www/i2p.www/i2p.wsgi                   && \  
+    ## Copy the unmodified vhosts file to the apache2 confdir
+    cp etc/apache2.i2p.conf /etc/apache2/sites-available/i2p.conf  && \  
+    a2enmod wsgi                                     && \
+    a2ensite i2p && \
+    ls /etc/apache2 && \
+    sed -i 's|IncludeOptional sites-enabled|# IncludeOptional sites-enabled|g' /etc/apache2/apache2.conf && \
+    sed -i '1 i\IncludeOptional sites-enabled/i2p.conf' /etc/apache2/apache2.conf && \
+    cat /etc/apache2/apache2.conf
+
+CMD service apache2 restart && tail -f /var/log/apache2/access.log
diff --git a/README.md b/README.md
index 82eb5b71d..d4b3271e9 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@ To run locally (for testing purposes):
 - Pull in the dependencies:
 
     ```
-    $ proxychains ./setup_venv.sh
+    $ proxychains ./setup_venv.qsh
     ```
 
     (you can also pull them non-anon by leaving out proxychains)
diff --git a/etc/apache2.i2p.conf b/etc/apache2.i2p.conf
new file mode 100644
index 000000000..783da09a8
--- /dev/null
+++ b/etc/apache2.i2p.conf
@@ -0,0 +1,18 @@
+<VirtualHost *:80>
+	#change ServerName and ServerAdmin to your own.
+	ServerName www.geti2p.net
+	ServerAdmin example@geti2p.net
+	DocumentRoot /var/www/i2p.www
+	WSGIDaemonProcess i2p2www user=www-data group=www-data threads=2
+	WSGIScriptAlias / /var/www/i2p.www/i2p.wsgi
+
+	<Directory /var/www/i2p.www/>
+	WSGIProcessGroup i2p2www
+	WSGIApplicationGroup %{GLOBAL}
+	WSGIScriptReloading On
+	</Directory>
+
+	ErrorLog ${APACHE_LOG_DIR}/error.log
+	CustomLog ${APACHE_LOG_DIR}/access.log combined
+
+</VirtualHost>
diff --git a/site-updater-docker.sh b/site-updater-docker.sh
new file mode 100755
index 000000000..3e3c3d40e
--- /dev/null
+++ b/site-updater-docker.sh
@@ -0,0 +1,7 @@
+#! /usr/bin/env sh
+
+git pull origin master
+docker build -t i2p-mirror/i2p.www .
+docker rm -f mirror.i2p.www
+docker run -it --name mirror.i2p.www -p 0.0.0.0:8090:80 i2p-mirror/i2p.www
+#docker run -td --name mirror.i2p.www --restart=always -p 0.0.0.0:5000:5000 i2p-mirror/i2p.www
-- 
GitLab