Closed justmike1 closed 1 year ago
Sorry this sort of question is beyond our expertise. If you can tell us what is missing from the experimental python image, perhaps we can help.
@loosebazooka From what I have researched, the library of default-libmysqlclient-dev
Also, the ENV line:
ENV DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$PATH"
Was a test I have done which didn't help, unrelated to source Dockerfile (removed)
so changing the dialect driver from mysql
to pymysql
did the trick. I wouldn't say this issue is closed, because using the mysql
driver is typically better as it's sourced on C, but a compiler needs to be included in the image.
Not sure if you want to give a different image a try, but we might be able to help get this working with the images at cgr.dev/chainguard/python - it's a bit easier to get extra C dependencies configured in them.
FWIW this works:
$ docker run -u root -it --entrypoint=sh cgr.dev/chainguard/python:latest-dev
$ apk add mariadb-dev cmd:mariadb_config
$ pip install mysqlclient
# python
Python 3.11.3 (main, Jan 1 1970, 00:00:00) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> print(MySQLdb.version_info)
(2, 1, 1, 'final', 0)
>>>
What is the difference between distroless to chainguard? I am typically always going towards google's distroless but I am not aware of chainguard.
The Chainguard images are still OSS and "distroless", just based on a new distro called Wolfi designed for this use case instead of debian. A lot of us were involved in creating this project here originally, and we tried to fix a lot of the issues with these new versions. The source for packages is here: https://github.com/wolfi-dev/os
Some more background: https://www.chainguard.dev/unchained/celebrating-6-years-of-distroless
They're both distroless style images and serve very similar purposes and you're probably okay using either? They're built slightly differently: distroless based off debian, while chainguard images are based on wolfi.dev.
I think you'll find that while distroless is scoped to a pretty limited number of images, wolfi/chaninguard has a wide catalogue of images so you might find the wolfi team more flexible to creating or changing images that match your specific needs.
I see now, thank you guys! I set this one as closed. TIL
@loosebazooka @dlorenc
Probably different issue from the same cause, I think having the c essentials are mandatory for a python package.
Describe the bug A clear and concise description of what the bug is.
To Reproduce An app which uses sqlalchemy to connect to mysql db with
self.engine_str = f'mysql://{self.username}:{self.password}@{self.host}:{self.port}/{self.database}'
Expected behavior
The app runs without mysql import error
Console Output
Additional context I tried using images:
FROM gcr.io/distroless/python3-debian11
FROM gcr.io/distroless/python3-debian10
FROM gcr.io/distroless/python3
I tried also using deb-extractor hack: