aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author0livd <github@destras.fr>2017-10-25 23:37:55 +0200
committerAlexis Metaireau <alexis@notmyidea.org>2017-10-25 23:37:55 +0200
commitb4961f646a6e265451aa414df9fb0d58b552ffdf (patch)
treec805e96cff799b257af4fdea8004b3bc6272c90c
parent293735eca715c7cc5221e551e5eb41f92b6abd0f (diff)
downloadihatemoney-mirror-b4961f646a6e265451aa414df9fb0d58b552ffdf.zip
ihatemoney-mirror-b4961f646a6e265451aa414df9fb0d58b552ffdf.tar.gz
ihatemoney-mirror-b4961f646a6e265451aa414df9fb0d58b552ffdf.tar.bz2
Add a DockerFile (#272)
Can be used to deploy the latest version from PyPI in a production environment or from the master branch in a dev environment.
-rw-r--r--CHANGELOG.rst1
-rw-r--r--Dockerfile34
-rwxr-xr-xconf/confandrun.sh23
-rw-r--r--docs/installation.rst36
4 files changed, 93 insertions, 1 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index c2dba84..260e6ff 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -30,6 +30,7 @@ Added
- Projects can be edited/deleted from the dashboard (#262)
- ACTIVATE_ADMIN_DASHBOARD setting (#262)
- Link to the dashboard in the navigation bar (#262)
+- Dockerfile
Removed
=======
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..ba2752a
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,34 @@
+FROM python:3.6-alpine
+
+RUN mkdir /ihatemoney &&\
+ mkdir -p /etc/ihatemoney &&\
+ pip install --no-cache-dir gunicorn pymysql
+
+WORKDIR /ihatemoney
+COPY . .
+ARG INSTALL_FROM_PYPI="False"
+RUN if [ "$INSTALL_FROM_PYPI" = True ]; then\
+ pip install --no-cache-dir ihatemoney ; else\
+ pip install --no-cache-dir -e . ; \
+ fi
+
+ENV DEBUG="False" \
+ SQLALCHEMY_DATABASE_URI="sqlite:////database/ihatemoney.db" \
+ SQLALCHEMY_TRACK_MODIFICATIONS="False" \
+ SECRET_KEY="tralala" \
+ MAIL_DEFAULT_SENDER="('Budget manager', 'budget@notmyidea.org')" \
+ MAIL_SERVER="localhost" \
+ MAIL_PORT=25 \
+ MAIL_USE_TLS=False \
+ MAIL_USE_SSL=False \
+ MAIL_USERNAME=None \
+ MAIL_PASSWORD=None \
+ ACTIVATE_DEMO_PROJECT="True" \
+ ADMIN_PASSWORD="" \
+ ALLOW_PUBLIC_PROJECT_CREATION="True" \
+ ACTIVATE_ADMIN_DASHBOARD="False" \
+ GUNICORN_NUM_WORKERS="3"
+
+VOLUME /database
+EXPOSE 8000
+CMD ["/ihatemoney/conf/confandrun.sh"]
diff --git a/conf/confandrun.sh b/conf/confandrun.sh
new file mode 100755
index 0000000..e76a8e8
--- /dev/null
+++ b/conf/confandrun.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+cat <<EOF >> /etc/ihatemoney/ihatemoney.cfg
+DEBUG = $DEBUG
+SQLALCHEMY_DATABASE_URI = "$SQLALCHEMY_DATABASE_URI"
+SQLACHEMY_DEBUG = DEBUG
+SQLALCHEMY_TRACK_MODIFICATIONS = $SQLALCHEMY_TRACK_MODIFICATIONS
+SECRET_KEY = "$SECRET_KEY"
+MAIL_SERVER = "$MAIL_SERVER"
+MAIL_PORT = $MAIL_PORT
+MAIL_USE_TLS = $MAIL_USE_TLS
+MAIL_USE_SSL = $MAIL_USE_SSL
+MAIL_USERNAME = "$MAIL_USERNAME"
+MAIL_PASSWORD = "$MAIL_PASSWORD"
+MAIL_DEFAULT_SENDER = "$MAIL_DEFAULT_SENDER"
+ACTIVATE_DEMO_PROJECT = $ACTIVATE_DEMO_PROJECT
+ADMIN_PASSWORD = "$ADMIN_PASSWORD"
+ALLOW_PUBLIC_PROJECT_CREATION = $ALLOW_PUBLIC_PROJECT_CREATION
+ACTIVATE_ADMIN_DASHBOARD = $ACTIVATE_ADMIN_DASHBOARD
+EOF
+gunicorn ihatemoney.wsgi:application \
+-b 0.0.0.0:8000 \
+--log-syslog \
+-w "$GUNICORN_NUM_WORKERS"
diff --git a/docs/installation.rst b/docs/installation.rst
index 9fd96b7..4a3aeae 100644
--- a/docs/installation.rst
+++ b/docs/installation.rst
@@ -56,7 +56,7 @@ Deploy it
=========
Now, if you want to deploy it on your own server, you have many options.
-Two of them are documented at the moment.
+Three of them are documented at the moment.
*Of course, if you want to contribute another configuration, feel free to open a
pull-request against this repository!*
@@ -113,6 +113,40 @@ With Nginx, Gunicorn and Supervisord
.. [#nginx-vhosts] typically, */etc/nginx/conf.d/* or
*/etc/nginx/sites-available*, depending on your distribution.
+With Docker
+-----------
+
+Build the image::
+
+ docker build -t ihatemoney --build-arg INSTALL_FROM_PYPI=True .
+
+Start a daemonized Ihatemoney container::
+
+ docker run -d -p 8000:8000 ihatemoney
+
+Ihatemoney is now available on http://localhost:8000.
+
+All Ihatemoney settings can be passed with ``-e`` parameters
+e.g. with a secure ``SECRET_KEY``, an external mail server and an external database::
+
+ docker run -d -p 8000:8000 \
+ -e SECRET_KEY="supersecure" \
+ -e SQLALCHEMY_DATABASE_URI="mysql+pymysql://user:pass@172.17.0.5/ihm" \
+ -e MAIL_SERVER=smtp.gmail.com \
+ -e MAIL_PORT=465 \
+ -e MAIL_USERNAME=your-email@gmail.com \
+ -e MAIL_PASSWORD=your-password \
+ -e MAIL_USE_SSL=True \
+ ihatemoney
+
+A volume can also be specified to persist the default database file::
+
+ docker run -d -p 8000:8000 -v /host/path/to/database:/database ihatemoney
+
+The following gunicorn parameters are also available::
+
+ GUNICORN_NUM_WORKERS (default: 3)
+
Configuration
=============