karrioapi / karrio

Programmable Shipping APIs (self-hosted)
https://karrio.io
Apache License 2.0
560 stars 104 forks source link

Docker image for api doesnt container mysql dependency #726

Open addshore opened 2 days ago

addshore commented 2 days ago

Describe the bug When trying to use etiher lates-rc or 2024.9.15 from https://hub.docker.com/r/karrio/server/tags, with mysql as a backend you ultimately end up with the following error.

karrio.api  | Traceback (most recent call last):
karrio.api  |   File "/karrio/venv/lib/python3.11/site-packages/django/db/backends/mysql/base.py", line 15, in <module>
karrio.api  |     import MySQLdb as Database
karrio.api  | ModuleNotFoundError: No module named 'MySQLdb'

Expected behavior I would expect the clients for all DBs that can be used to be installed in such an image

Additional context I can also imagine that you might say, no, we only support the defaults, in which case, happy to just get this close and I'll go and make my own image.

jacobshilitz commented 2 days ago

although in 2023.1 added support to mysql and such, the main db and the db used my the devs is postgresql...

I would recommend to use postgresql if you run it in docker anyway

addshore commented 1 day ago

So we primarily use mysql in production, and ideally would just add this as another db on an existing host, rather than needing to provision a new host for postgresql and then also maintain that etc. Using the docker images and docker-compose was just testing the proof of concept locally, and for a local dev environment before moving forward with production.

This was my first attempt trying to run it with mysql and ran into an issue https://github.com/karrioapi/karrio/issues/727 I have no idea if thats an easy one to fix?

But I ultimately got to a working version of a dockerfile (even if a bit ugly) with the following:

FROM karrio/server:2024.9.15

USER root

RUN apt install -y pkg-config default-libmysqlclient-dev

RUN python -m venv /karrio/venv
ENV PATH="/karrio/venv/bin:$PATH"
RUN cd /karrio/ && \
    pip install --upgrade pip && \
    pip install dumb-init && \
    pip install mysqlclient

USER karrio 
danh91 commented 1 day ago

Hi @addshore , @jacobshilitz is right that even though Django supports MySQL, we’ve been working with Postgres and some of the errors I saw on your logs looked like index incompatibilities.

I imagine that getting to compatibility and fully testing the project with MySQL is going to require a lot of time. I personally don’t think I will be able to tackle that anytime soon.

I would also recommend spinning up a Postgres instance for now to familiarize yourself with the project and we can prioritize the mysql compatibility later.