Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Dockerfile to compile python dependencies at build time. #793

Merged
merged 1 commit into from
Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git
.github
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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