GithubHelp home page GithubHelp logo

Help Dockerizing Lute about lute HOT 13 CLOSED

jzohrab avatar jzohrab commented on September 25, 2024 1
Help Dockerizing Lute

from lute.

Comments (13)

99MengXin avatar 99MengXin commented on September 25, 2024 2

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"]

from lute.

16amattice avatar 16amattice commented on September 25, 2024

What is the default environment that SQL is expecting here?

environment:
  MYSQL_DATABASE: lute
  MYSQL_USER: lute
  MYSQL_PASSWORD: password
  MYSQL_ROOT_PASSWORD: password

from lute.

jzohrab avatar jzohrab commented on September 25, 2024

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

from lute.

AdamHebby avatar AdamHebby commented on September 25, 2024

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

from lute.

jzohrab avatar jzohrab commented on September 25, 2024

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

from lute.

AdamHebby avatar AdamHebby commented on September 25, 2024

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.

from lute.

jzohrab avatar jzohrab commented on September 25, 2024

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.

from lute.

16amattice avatar 16amattice commented on September 25, 2024

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

from lute.

jzohrab avatar jzohrab commented on September 25, 2024

Super, thank you @16amattice .

from lute.

16amattice avatar 16amattice commented on September 25, 2024

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.

from lute.

jzohrab avatar jzohrab commented on September 25, 2024

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:

  • prebuilt images pushed to docker hub, with the full app code in the image
  • storing the db and the images in mounted volume

from lute.

jzohrab avatar jzohrab commented on September 25, 2024

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

from lute.

16amattice avatar 16amattice commented on September 25, 2024

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!

from lute.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.