Question:
How to Install mariaDB client efficiently inside docker?

To install the MariaDB client efficiently inside a Docker container, you have to save the code in a file named Dockerfile. 


In the same directory, you might have your SQL scripts or other files that you want to copy into the container.


Here's a Dockerfile code to get you started:

FROM python:3.12 as mysqlclient-build

RUN curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | bash 

RUN apt-get update

RUN apt-get install -y mariadb-client libmariadb-dev-compat libmariadb-dev

RUN pip wheel -w /deps mysqlclient


FROM python:3.12

COPY --from=mysqlclient-build /deps/*.whl /deps

RUN pip install /deps/*.whl && rm -rf /deps

# ... the rest of your actual application bits


Use >a multi-stage build to build the mysqlclient wheel in the first stage, then copy it over to the runtime stage. This leaves gcc and friends only in the build stage.


You can of course do this for all of your requirements.txt too – pip wheel -w /deps -r requirements.txt or whatnot.


Suggested blogs:

>What is microservice architecture, and why is it better than monolithic architecture?

>What is pipe in Angular?

>What makes Python 'flow' with HTML nicely as compared to PHP?

>What to do when MQTT terminates an infinite loop while subscribing to a topic in Python?

>Creating custom required rule - Laravel validation

>How to configure transfers for different accounts in stripe with laravel?

>Laravel Query Solved: Laravel withOnly not restricting the query

>Laravel installation problem: Fix failed to download laravel/laravel from dist- Laravel (v10.2.6)



Submit
0 Answers