I have a "point of sales" application in Django that uses a mysql database.
I followed this Docker guide: Python getting started guide
In order to setup the mysql container I created a couple of volumes and its network:
docker volume create mysql
docker volume create mysql_config
docker network create mysqlnet
My Dockerfile looks like this:
(I don't want to use docker-compose yet becouse I want to learn the bases)
Dockerfile
# syntax=docker/dockerfile:1
FROM python:3.8-slim-buster
RUN apt update
RUN apt upgrade -y
RUN apt dist-upgrade
RUN apt-get install procps -y
RUN apt install curl -y
RUN apt install net-tools -y
WORKDIR /home/pos
COPY requirements.txt ./.
RUN pip3 install -r requirements.txt
COPY ./src ./src
CMD ["python", "./src/manage.py", "runserver", "0.0.0.0:8000"]
And in the Django project my database settings and requirements looks like:
settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'point-of-sales',
'USER': 'root',
'PASSWORD': 'r00t',
'HOST': 'localhost',
'PORT': '3307'
}
}
requirements.txt
# Django
django>=3.1,<3.2
# DRF
djangorestframework>=3.12,<3.13
# Databases
mysqlclient
What I want is to build an image of the Django application that I could run and attach to the mysql network.
The problem is that I can't build the image of my django app becouse it throws the following error when trying to install mysqlclient:
OSError: mysql_config not found
Looking around I found another topic that suggest to install mysql-config which is another package but I want to kept everything of mysql isolated in the mysql container.
Is there any way to do that without using docker-compose?