ols-docker-env icon indicating copy to clipboard operation
ols-docker-env copied to clipboard

Enable use of an existing MySQL server by simply setting MYSQL_HOST in the .env file.

Open josh208 opened this issue 1 year ago • 4 comments

Simply uncomment MYSQL_HOST in .env and set appropriately to use an existing MySQL server.

Additional change: By default, docker compose will NOT deploy the MySQL nor phpMyAdmin services (regardless of MYSQL_HOST setting. To deploy these the user must add '--profile database' to the docker compose command.

Documentation has been updated.

I have done a full run-through and Wordpress fired right up. Also did a test without MYSQL_HOST set and with --profile database and got the stack running with the included MySQL/phpMyAdmin services.

josh208 avatar Sep 22 '24 10:09 josh208

Hi @josh208 Both mysql and phpmyadmin are deployed and run by default. See the following example.

git clone https://github.com/litespeedtech/ols-docker-env.git
cd ols-docker-env
docker compose up -d

Run curl -Ik https://127.0.0.1:8443, and it returns HTTP/1.1 200 OK. You can also open the phpmyadmin on the browser and log in with the db credential, which means both services are up and running. Can you give it a try, if it works, then we don't need to add --profile.

Code-Egg avatar Sep 25 '24 07:09 Code-Egg

I am aware that phpMyAdmin and MySQL (technically MariaDB) are deployed by default. The purpose of this PR is to add an enhancement that allows the user to skip deployment of phpMyAdmin/MySQL and instead specify their own existing MySQL DB. It's not an uncommon use-case to have an existing MySQL instance already setup. I run my environment in Google Cloud and have a Google Cloud SQL instance that is far more robust than what would be run locally in a small cloud compute instance. Again, this is not an uncommon scenario.

josh208 avatar Sep 25 '24 16:09 josh208

It occurs to me that the confusion may come from the following statement that I made...

Additional change: By default, docker compose will NOT deploy the MySQL nor phpMyAdmin services (regardless of MYSQL_HOST setting. To deploy these the user must add '--profile database' to the docker compose command.

What I was saying is that with my change, phpMyAdmin / MySQL will not deploy by default and user muse add '--profile database' to do so.

If this PR would otherwise be accepted, I could modify so that default behavior is only changed IF MYSQL_HOST is set.

josh208 avatar Sep 25 '24 16:09 josh208

Thanks for the details! I see what you mean now. The README is also a bit unclear, so I’ll take another look at it next week."

To use an existing MySQL server
docker compose up -d
Note: Be sure to uncomment, and set MYSQL_HOST in the .env file

To use the included MySQL Server (as well as phpMyAdmin)
docker compose --profile database up -d
Note: Be sure MYSQL_HOST is commented out in the .env file

Note: If you wish to run a single web server container, please see the [usage method here](https://github.com/litespeedtech/ols-dockerfiles#usage).

Code-Egg avatar Sep 27 '24 12:09 Code-Egg