LinguaCafe icon indicating copy to clipboard operation
LinguaCafe copied to clipboard

Please add external MySQL support

Open xXAzazelXx opened this issue 1 year ago • 2 comments

Hey !

Is it please possible to add support for var to point to external MySQL??

similar to this:

DB_DATABASE="linguacafe" DB_USERNAME="linguacafe" DB_PASSWORD="linguacafe"

eg DB_HOST=

xXAzazelXx avatar May 17 '24 14:05 xXAzazelXx

Sure, it can be added. Actually, you can add it yourself in the meantime I think.

You can modify the docker-compose.yml if you are using v0.12:

    webserver:
        image: ghcr.io/simjanos-dev/linguacafe-webserver:${VERSION:-latest}
        container_name: linguacafe-webserver
        restart: unless-stopped
        depends_on:
            - mysql
        volumes:
            - ./storage:/var/www/html/storage
        environment:
            DB_DATABASE: ${DB_DATABASE:-linguacafe}
            DB_USERNAME: ${DB_USERNAME:-linguacafe}
            DB_PASSWORD: ${DB_PASSWORD:-linguacafe}
            DB_HOST: ${DB_HOST:-linguacafe-database}
            DB_PORT: ${DB_PORT:-3306}

Then add these variables to a .env file.

At startup it will create the necessary tables, but you will have to create the database itself before that.

simjanos-dev avatar May 17 '24 15:05 simjanos-dev

OK that worked, i just had to get rid of "" in the .env

Thank you!

xXAzazelXx avatar May 17 '24 23:05 xXAzazelXx

I added support for this in the docker-compose.yml files in the repo.

@sergiolaverde0: Could you please double check if it's good? I'm a bit paranoid with docker. I tested it, it works for me. I assumed only the port number must be without "" marks.

Here's the commit.

simjanos-dev avatar May 21 '24 20:05 simjanos-dev

I tested it without the quotes since I remembered them not being needed; after all, our default values are without quotes.

I tested it with Spanish as per not to spend time waiting for Japanese to be installed and it all seemed to work minus for a weird error message when trying to finish a chapter. After testing using quotes and using the default values I found the behaviour was the same. So quotes are optional and it all "works" except for a bug that seems to be entirely unrelated.

Later this week I will test more and open an issue once I get more info, but your changes are good to go.

sergiolaverde0 avatar May 22 '24 03:05 sergiolaverde0

Thank you!

simjanos-dev avatar May 22 '24 07:05 simjanos-dev

minus for a weird error message when trying to finish a chapter

Couldn't reproduce today with none of Japanese, Spanish nor English so let's call it a red herring and hope it doesn't happen again.

sergiolaverde0 avatar May 22 '24 23:05 sergiolaverde0

@xXAzazelXx

Hi!

Do you use linguacafe yourself, or do you host it for someone else?

I made a mistake in a function, that affects your use-case. Any user that is logged in to linguacafe can request any laravel config values, which includes MySQL host/database/username/password. I'll release a hotfix.

simjanos-dev avatar Jun 01 '24 17:06 simjanos-dev

Just myself, local only

xXAzazelXx avatar Jun 02 '24 00:06 xXAzazelXx

Then it could have caused no problems, and the hotfix is released now.

simjanos-dev avatar Jun 02 '24 09:06 simjanos-dev