Skip to content

Commit

Permalink
Change Dockerfile to compile python dependencies at build time.
Browse files Browse the repository at this point in the history
- Updated entrypoint.sh
- Updated docs for running with Docker
- Added .dockerignore
  • Loading branch information
wrecker authored and zorun committed Jul 14, 2021
1 parent 078f9e8 commit 942617a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 26 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
@@ -0,0 +1,2 @@
.git
.github
12 changes: 6 additions & 6 deletions Dockerfile
@@ -1,7 +1,6 @@
FROM python:3.7-alpine

ENV NIGHTLY="" \
DEBUG="False" \
ENV DEBUG="False" \
SQLALCHEMY_DATABASE_URI="sqlite:////database/ihatemoney.db" \
SQLALCHEMY_TRACK_MODIFICATIONS="False" \
SECRET_KEY="tralala" \
Expand All @@ -19,12 +18,13 @@ ENV NIGHTLY="" \
BABEL_DEFAULT_TIMEZONE="UTC" \
GREENLET_TEST_CPP="no"

RUN apk update && apk add git gcc libc-dev libffi-dev openssl-dev wget &&\
mkdir -p /etc/ihatemoney &&\
RUN mkdir -p /etc/ihatemoney &&\
pip install --no-cache-dir gunicorn pymysql;

COPY ./conf/entrypoint.sh /entrypoint.sh
ADD . /src

RUN pip install --no-cache-dir -e /src

VOLUME /database
EXPOSE 8000
ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/src/conf/entrypoint.sh"]
18 changes: 0 additions & 18 deletions conf/entrypoint.sh
Expand Up @@ -23,24 +23,6 @@ ACTIVATE_ADMIN_DASHBOARD = $ACTIVATE_ADMIN_DASHBOARD
BABEL_DEFAULT_TIMEZONE = "$BABEL_DEFAULT_TIMEZONE"
EOF

if [ "$NIGHTLY" == "True" -o "$NIGHTLY" == "true" ]; then
# Clone or update repository into /ihatemoney.
if [ ! -d /ihatemoney/.git ]; then
echo "Cloning..."
git clone --depth 1 https://github.com/spiral-project/ihatemoney /ihatemoney
echo "Done cloning."
else
cd /ihatemoney
echo "Updating..."
git pull || echo "Couldn't update; maybe Github is unreachable?"
echo "Done updating."
fi
pip install --no-cache-dir -e /ihatemoney
else
# Get the latest release from PyPI.
pip install --no-cache-dir --upgrade ihatemoney
fi

# Start gunicorn without forking
exec gunicorn ihatemoney.wsgi:application \
-b 0.0.0.0:8000 \
Expand Down
14 changes: 12 additions & 2 deletions docs/installation.rst
Expand Up @@ -207,7 +207,7 @@ With Docker

Build the image::

docker build -t ihatemoney --build-arg INSTALL_FROM_PYPI=True .
docker build -t ihatemoney .

Start a daemonized Ihatemoney container::

Expand All @@ -233,7 +233,17 @@ 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

If you want to run the latest version, you can pass `-e NIGHTLY="true"`.
To enable the Admin dashboard, first generate a hashed password with::

docker run -it --rm --entrypoint ihatemoney ihatemoney generate_password_hash

At the prompt, enter a password to use for the admin dashboard. The
command will print the hashed password string.

Add these additional environment variables to the docker run invocation::

-e ACTIVATE_ADMIN_DASHBOARD=True \
-e ADMIN_PASSWORD=<hashed_password_string> \

Additional gunicorn parameters can be passed using the docker ``CMD``
parameter.
Expand Down

0 comments on commit 942617a

Please sign in to comment.