Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧑‍💻 Update docker environment and optimise for local development #2074

Merged
merged 3 commits into from
Mar 11, 2024

Conversation

jeyemwey
Copy link
Contributor

As asked in the discord, I simplified the docker compose environment so it is more usable in local development.

This PR does a few things:

  • Document how the docker-compose environment works
  • Remove two unused/redundant compose files
  • Clean up the remaining docker-compose.yml to always use the local build and a .env.docker
  • Hide/Ignore state files from devenv/direnv and docker volumes more strictly

I hope that traewelling and laravel newbies can work with the changes better and contribute to the project quicker.

Meta: There are a bunch of changes in a large number of files, so especially for the README.md and the docker-compose.yml it would be helpful to just read through the final result.

Copy link

@pReya pReya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much @jeyemwey! I appreciate all these changes. I have just two questions/concerns.

README.md Outdated Show resolved Hide resolved
docker-compose.yml Show resolved Hide resolved
Copy link

@pReya pReya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without specifying the git hash and just using the 5 version number for derhuerst/db-rest, I can finally build/start the project on my M1/ARM Mac. Thanks!

However I'm still getting tons of errors from the seeding process:

2023-10-23 18:41:33 Seeding database
2023-10-23 18:41:33 
2023-10-23 18:41:33   Dropping all tables ............................................... 4ms FAIL
2023-10-23 18:41:33 
2023-10-23 18:41:33    UnexpectedValueException 
2023-10-23 18:41:33 
2023-10-23 18:41:33   There is no existing directory at "/usr/src/trwl/storage/logs" and it could not be created: Permission denied
2023-10-23 18:41:33 
2023-10-23 18:41:33   at vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:197
2023-10-23 18:41:33     193▕             set_error_handler([$this, 'customErrorHandler']);
2023-10-23 18:41:33     194▕             $status = mkdir($dir, 0777, true);
2023-10-23 18:41:33     195▕             restore_error_handler();
2023-10-23 18:41:33     196▕             if (false === $status && !is_dir($dir) && strpos((string) $this->errorMessage, 'File exists') === false) {
2023-10-23 18:41:33   ➜ 197▕                 throw new \UnexpectedValueException(sprintf('There is no existing directory at "%s" and it could not be created: '.$this->errorMessage, $dir));
2023-10-23 18:41:33     198▕             }
2023-10-23 18:41:33     199▕         }
2023-10-23 18:41:33     200▕         $this->dirCreated = true;
2023-10-23 18:41:33     201▕     }
2023-10-23 18:41:33 
2023-10-23 18:41:33       +10 vendor frames 
2023-10-23 18:41:33 
2023-10-23 18:41:33   11  app/Exceptions/Handler.php:41
2023-10-23 18:41:33       Illuminate\Foundation\Exceptions\Handler::report(Object(Illuminate\Database\QueryException))
2023-10-23 18:41:33       +3 vendor frames 
2023-10-23 18:41:33 
2023-10-23 18:41:33   15  artisan:37
2023-10-23 18:41:33       Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

README.md Outdated Show resolved Hide resolved
networks:
- internal
environment:
- TZ=Europe/Berlin
env_file:
- .env.docker

db-rest:
# we are stuck on db-rest version 5,
image: derhuerst/db-rest@sha256:c2373bf5765a2b7e952753acbd2533b747fe1a3e29bb3759db50cdf69f077618
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
image: derhuerst/db-rest@sha256:c2373bf5765a2b7e952753acbd2533b747fe1a3e29bb3759db50cdf69f077618
image: derhuerst/db-rest:5

@pReya
Copy link

pReya commented Oct 31, 2023

@jeyemwey Do you mind taking a look at the errors from my latest post? Any idea, why the seeding fails due to permission problems?

@jeyemwey
Copy link
Contributor Author

I'm currently on holiday and don't have a development environment with me. Please give me another week or so until I can merge the things into develop. I don't reckon that other maintainers want to do much of a review here, but your critique has been super helpful.

In the mean time, can you try creating the subfolders on the host system? Maybe it's just a permissions thing.

@pReya
Copy link

pReya commented Nov 22, 2023

I'm currently on holiday and don't have a development environment with me. Please give me another week or so until I can merge the things into develop. I don't reckon that other maintainers want to do much of a review here, but your critique has been super helpful.

In the mean time, can you try creating the subfolders on the host system? Maybe it's just a permissions thing.

Could you take another look? The subfolders already exist on the host system

@jeyemwey
Copy link
Contributor Author

Hi, sorry for the long wait.

I have pushed 1cd3472 and 4dc0564 which address a number of issues:

  • The version tag of db-rest has been updated as proposed.
  • The seeding now runs in the application directory (/var/www/html) and only in the app container. This should resolve the There is no existing directory at "/usr/src/trwl/storage/logs" and it could not be created: Permission denied. error.
  • SEED_DB now generates OAuth master keys (and overwrites existing ones on restart). This allows the app to hand out client keys which is necessary for third party apps and various lazy-loaded elements in the frontend (i.e. the notifications).
  • Documented what SEED_DB does and described that avatars from the UserFactory need to be present in the avatars volume mount.

I have now tested (on my M1 mac) like this:

cd /tmp
git clone git@github.com:Traewelling/traewelling.git
cd traewelling
git checkout dev/jv/docker-env
vi docker-compose.yml # to activate the `SEED_DB` env
docker-compose up --build -d
# wait until the containers are ready
open "http://localhost:8081"

Please check and let me know if it works for you :)

@MrKrisKrisu MrKrisKrisu requested a review from pReya March 10, 2024 17:44
@MrKrisKrisu MrKrisKrisu added the stale stale pr's that apparently are no longer maintained label Mar 10, 2024
@MrKrisKrisu
Copy link
Member

Hey @jeyemwey and @pReya, can you please have a look on this PR, as this is open for a long time now without any interactions? Thanks!

@jeyemwey
Copy link
Contributor Author

From my side, it's good to go, but I haven't tested on anything but my Mac.

@MrKrisKrisu
Copy link
Member

MrKrisKrisu commented Mar 10, 2024

From my side, it's good to go, but I haven't tested on anything but my Mac.

Then I would suggest that we merging this soon if nobody puts a veto. :)

@MrKrisKrisu MrKrisKrisu added the docker Pull requests that update Docker code label Mar 10, 2024
@MrKrisKrisu MrKrisKrisu merged commit bb2365e into develop Mar 11, 2024
10 checks passed
@MrKrisKrisu MrKrisKrisu deleted the dev/jv/docker-env branch March 11, 2024 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docker Pull requests that update Docker code stale stale pr's that apparently are no longer maintained
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants