Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Commit apache docker file

Roland Geider0f12ccdccc0a
diff --git a/docs/docker.rst b/docs/docker.rst
index a5e2fa962..bb2497323 100644
--- a/docs/docker.rst
+++ b/docs/docker.rst
@@ -38,4 +38,21 @@ code on your host machine and use docker only to serve it. Then you can do this:
It will mount the local path *on top* of the folder in the container, basically
exchanging one for the other. Please note that for this to work you need to
manually checkout the code to ``/path/to/local/wger/`` and create a settings file
-as well.
\ No newline at end of file
+as well.
+
+
+Apache
+------
+
+This image runs the application using WSGI and apache.
+
+First build the image::
+
+ docker build -t wger/apache .
+
+Run a container and start the application::
+
+ docker run -ti --name wger.apache --publish 80:8000 wger/apache
+
+Now you can access the application on port 8000 of your host (probably just
+http://localhost:8000).
\ No newline at end of file
diff --git a/extras/docker/apache/Dockerfile b/extras/docker/apache/Dockerfile
new file mode 100644
index 000000000..232ab7bea
--- /dev/null
+++ b/extras/docker/apache/Dockerfile
@@ -0,0 +1,64 @@
+#
+# Dockerimage for wger development
+#
+# Please consult the documentation for usage
+#
+#
+
+FROM ubuntu:15.04
+
+MAINTAINER Roland Geider <[email protected]>
+EXPOSE 80
+
+# Install dependencies
+RUN apt-get update;\
+ apt-get install -y apache2 libapache2-mod-wsgi \
+ nodejs nodejs-legacy npm git \
+ python-virtualenv python3-dev \
+ libjpeg8-dev zlib1g-dev libwebp-dev \
+ sudo vim
+
+# Add wger user
+RUN adduser wger --disabled-password --gecos ""
+RUN echo "wger ALL=(ALL) NOPASSWD:ALL" > etc/sudoers.d/wger
+
+# Configure apache
+RUN a2dissite 000-default.conf
+ADD wger.conf /etc/apache2/sites-available/
+RUN a2ensite wger
+
+# Set up the application
+USER wger
+RUN git clone https://github.com/rolandgeider/wger.git /home/wger/src
+RUN virtualenv --python python3 /home/wger/venv
+
+WORKDIR /home/wger/src
+RUN npm install bower \
+ && . /home/wger/venv/bin/activate \
+ && pip install --upgrade pip \
+ && pip install -r requirements_devel.txt \
+ && invoke create_settings \
+ --settings-path /home/wger/src/settings.py \
+ --database-path /home/wger/db/database.sqlite \
+ && invoke bootstrap_wger --settings-path /home/wger/src/settings.py --no-start-server
+
+# Change permissions of some files and folders so the apache process
+# can access them.
+WORKDIR /home/wger
+RUN chmod o+w ~/db/database.sqlite \
+ && mkdir static \
+ && mkdir media \
+ && chmod o+w media \
+ && sed -i "/^MEDIA_ROOT/c\MEDIA_ROOT='\/home\/wger\/media'" src/settings.py \
+ && echo STATIC_ROOT=\'/home/wger/static\' >> src/settings.py \
+ && mkdir /home/wger/src/components #WTF? \
+ && python manage.py collectstatic
+
+USER root
+RUN chmod 755 /usr/sbin/apache2ctl
+
+ENTRYPOINT ["/usr/sbin/apache2ctl"]
+CMD ["-D", "FOREGROUND"]
+
+#CMD ["/usr/sbin/apache2ctl -D FOREGROUND"]
+# CMD ["/bin/bash"]
diff --git a/extras/docker/apache/wger.conf b/extras/docker/apache/wger.conf
new file mode 100644
index 000000000..92c2495d1
--- /dev/null
+++ b/extras/docker/apache/wger.conf
@@ -0,0 +1,24 @@
+WSGIScriptAlias / /home/wger/src/wger/wsgi.py
+WSGIPythonPath /home/wger/src:/home/wger/venv/lib/python3.4/site-packages
+
+<Directory /home/wger/src>
+ <Files wsgi.py>
+ Require all granted
+ </Files>
+</Directory>
+
+
+<VirtualHost *:80>
+ Alias /static/ /home/wger/static/
+ <Directory /home/wger/static>
+ Require all granted
+ </Directory>
+
+ Alias /media/ /home/wger/media/
+ <Directory /home/wger//media>
+ Require all granted
+ </Directory>
+
+ ErrorLog ${APACHE_LOG_DIR}/error.log
+ CustomLog ${APACHE_LOG_DIR}/access.log combined
+</VirtualHost>