Closed jzohrab closed 1 year ago
What is the default environment that SQL is expecting here?
environment:
MYSQL_DATABASE: lute
MYSQL_USER: lute
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password
Hi @16amattice , I figure that the db container would be a full installation of MySQL with the default information, which in some cases can be supplied during installation. https://hub.docker.com/_/mysql has some notes.
Perhaps all of this stuff could be passed to docker compose as a config file. Not sure! Perhaps every user should just be using a default config w/ default environment, so that it can be installed and run with no extra configuration -- would also make the deployment more standard, so that users don't accidentally mess up their config.
All open for discussion, of course. This is meant to simplify things for users to install. :-) Does that make sense? Cheers, jz
Hello! Didn't see this discussion before I started working on it. Feel free to add to my PR, not got it fully working just yet, the tests can't connect to the test DB, think it needs some env changes
Hi @AdamHebby, thanks for the PR! I'll check it out -- have to get my Docker working first :-) Re the tests, it could be due to how Symfony manages the environments. When it's connecting to the regular DB, it uses .env
, or is overridden with .env.local
, but when running tests, it connects to .env.test
or .env.test.local
(ref https://symfony.com/doc/current/testing.html#customizing-environment-variables). Lute then requires the test database name to start with test_
, because the tests are destructive and I'm paranoid.
fyi, my .env.test.local looks like this:
$ cat .env.test.local
DB_DATABASE=test_lute
DB_HOSTNAME=localhost
DB_USER=root
DB_PASSWORD=root
DATABASE_URL=mysql://${DB_USER}:${DB_PASSWORD}@${DB_HOSTNAME}/${DB_DATABASE}?serverVersion=8&charset=utf8
Hi @jzohrab No worries! Yeah, it's mostly due to me assuming prod only and docker-compose only using .env, might either need a second docker-compose-test or something to only use the test env vars and run the app-init script with an argument to run the DB migrations on the test DB. Just needs a bit of thought around it is all.
Right, compose-test might make sense because then it's very explicit; or perhaps docker-compose-dev b/c really it's best to do dev in a specific environment. Whatever, as long as it's obvious for devs ... but then, maybe there would be a completely different setup for them (e.g. mounting the code dir as a volume or something), vs for end users (maybe everything just builds into the images?). I don't know what makes the most sense here. :-)
Lute manages the database migrations automatically ... every time the app connects to the db, it checks the db migrations to see if anything needs to be run. Yep, it's very wasteful :-) but it's just a single disk check for files against the db, so I didn't mind, and I don't notice it while running.
I'll have to look at this tomorrow as well...I got a base setup that I believe is almost ready to run...just some things I have to tweak. I'll look at the PR tomorrow as well in case we are doing double work here lol
Super, thank you @16amattice .
Not a problem! Looked a bit at the draft PR..and I added the composer install directly to the build. I made some other changes and am at the point of setting up the environment stuff. Just trying to stick with the portability aspect. I'll finish up tomorrow and throw a PR in.
Since @jzohrab release Lute v2-really-alpha, dockerise lute become very simple.
Make and put these two files in lute dir, and run docker compose up -d
.
Dockerfile
FROM php:8.2
# Install mecab for Japanese support
RUN apt-get update -y
RUN apt-get install -y mecab mecab-ipadic-utf8
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
WORKDIR /lute/public
CMD ["php", "-S", "0.0.0.0:8000"]
docker-compose.yml
version: "3.9"
services:
lute:
build:
context: ./
dockerfile: Dockerfile
container_name: lute_2
restart: always
ports:
- 8000:8000
volumes:
- .:/lute
working_dir: /lute/public
command: ["php", "-S", "0.0.0.0:8000"]
A great start, thank you @99MengXin ! I'm going to mess around with this a bit more before putting the dockerfile and compose into the repo. I'm going to see what I can do for the following:
Closing! The v2 beta has a working Docker image that runs well on a Mac. I'm going to assume that it will work on other systems as well ... and if it doesn't, then that's a separate dev ticket. Thanks to @16amattice , @AdamHebby , and @99MengXin for your notes, they all helped get this started. Cheers! jz
Closing! The v2 beta has a working Docker image that runs well on a Mac. I'm going to assume that it will work on other systems as well ... and if it doesn't, then that's a separate dev ticket. Thanks to @16amattice , @AdamHebby , and @99MengXin for your notes, they all helped get this started. Cheers! jz
Always happy to help and good luck!
Hello all, if you're reading this, perhaps you have Docker experience and can help Dockerize Lute.
I've had a few people ask about having Lute Dockerized. It's been a loooong time since I've hacked on Docker, and I don't have the time or energy to spend fiddling with it. Perhaps someone is looking for a Docker project to try out, and would be willing to contribute.
Below is some info, LMK if you need more. This is a free project, I'm not looking to make money from it, and so I can't pay anyone. Hopefully this doesn't make you feel you're being taken advantage of ... (as a dev, I used to always feel that certain types of ppl were leeching off me) ... my limited dev time is better spent working on Lute itself.
Cheers and best wishes!
Jeff
Specs for Lute:
More notes: