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

Production ready docker #919

Merged
merged 15 commits into from Nov 25, 2021
Merged

Production ready docker #919

merged 15 commits into from Nov 25, 2021

Conversation

youegraillot
Copy link
Contributor

@youegraillot youegraillot commented Nov 14, 2021

Some changes in this PR to make the docker image production ready :

  • /healthcheck endpoint usefull for monitoring, ci test also uses this
  • customizable PORT with environment variable
  • customizable PUID/PGID, reduce attack surface and allow better integration in rootless environments
  • size optimization
  • update to python 3.10
  • add postegresql compatibility

PUID/PGID default as root to not break current user environments

Copy link
Member

@Glandos Glandos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small remarks :)

Dockerfile Outdated
@@ -1,5 +1,8 @@
FROM python:3.7-alpine
FROM python:3.9-alpine
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using 3.10-alpine? Is it because we don't officially support it yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, didn't test with 3.10, but once tests are updated we should update this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can go ahead with 3.10 now that #921 was merged

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright !

docker-compose.test.yml Show resolved Hide resolved
Dockerfile Outdated
echo "**** create runtime folder ****" && \
mkdir -p /etc/ihatemoney &&\
echo "**** install pip packages ****" && \
pip install --no-cache-dir gunicorn pymysql && \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about installing psycopg2 too, so you can use a postgres database with the docker image?

Copy link
Contributor

@Nikos410 Nikos410 Nov 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried adding it afterwards by running from a simple local Dockerfile like this:

FROM ihatemoney/ihatemoney:5.1.1
RUN pip install --no-cache-dir psycopg2

But building fails, not sure why - I don't really have experience using python.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you tell us how it fails, maybe you have some logs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I've opened a proper Issue: #924

@almet
Copy link
Member

almet commented Nov 24, 2021

This seems good to me, thanks ! but as I don't understand a word about docker, I'll let @Glandos or @zorun review and merge this !

@zorun
Copy link
Collaborator

zorun commented Nov 24, 2021

Well done for the lightweight postgresql integration :)

I have one nitpick: tests are run with constrained versions of psycopg2 and pymysql defined in setup.py, currently:

psycopg2-binary>=2.9,<3
PyMySQL>=0.9,<1.1

It would be good to use the same constraints in the Docker image to avoid surprises.

I suggest moving these two dependencies out of the [dev] group and into a new [database] group, update the tox config to install this group instead of [dev], and also install this group in your Dockerfile (I think pip install -e /src[database] should work)

@youegraillot
Copy link
Contributor Author

Well done for the lightweight postgresql integration :)

I have one nitpick: tests are run with constrained versions of psycopg2 and pymysql defined in setup.py, currently:

psycopg2-binary>=2.9,<3
PyMySQL>=0.9,<1.1

It would be good to use the same constraints in the Docker image to avoid surprises.

I suggest moving these two dependencies out of the [dev] group and into a new [database] group, update the tox config to install this group instead of [dev], and also install this group in your Dockerfile (I think pip install -e /src[database] should work)

Good call, done !

@zorun zorun merged commit acb2799 into spiral-project:master Nov 25, 2021
@zorun
Copy link
Collaborator

zorun commented Nov 25, 2021

Looks good, thanks!

@youegraillot
Copy link
Contributor Author

I updated the dockerhub readme to include tags description, compose example and env list : https://hub.docker.com/r/ihatemoney/ihatemoney

@youegraillot
Copy link
Contributor Author

Also, we may want to trigger another deploy to make PORT,PGID and PUID options available to latest.

@zorun
Copy link
Collaborator

zorun commented Nov 25, 2021

You mean overwriting the last tagged release on the dockerhub? That does not look like a good idea. I guess we simply need to do a release soon.

@youegraillot
Copy link
Contributor Author

youegraillot commented Nov 25, 2021

That is what I meant ;)

Creating a new release after 5.1.1, thus pushing a new latest tag on dockerhub

@zorun zorun mentioned this pull request Dec 9, 2021
TomRoussel pushed a commit to TomRoussel/ihatemoney that referenced this pull request Mar 2, 2024
* /healthcheck endpoint usefull for monitoring, ci test also uses this
* customizable PORT with environment variable
* customizable PUID/PGID, reduce attack surface and allow better integration in rootless environments
* size optimization
* update to python 3.10
* add postgresql compatibility
* PUID/PGID default as root to not break current user environments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants