From e5244db6b08bf8ee1ea2d1b91958c902e4372474 Mon Sep 17 00:00:00 2001 From: overflowerror Date: Wed, 7 Aug 2024 23:40:12 +0200 Subject: [PATCH] doc: Add description of the local Docker setup to README --- .gitignore | 3 ++- README.md | 39 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 43777a1..759cb9b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea -config.php \ No newline at end of file +config.php +config2.php \ No newline at end of file diff --git a/README.md b/README.md index 7d6100f..3788355 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,9 @@ This project aims to unravel the answer to the gargantuan query of existential magnitude: Which is the best Minecraft mob? -Visitors are prompted with two mobs and should decide which one they like better. After they choose, the "looser" is replaced with a new candidate. In the background, an Elo-style rating system is keeping track of the individual matches. The rating also determines the next candidate - similar rating are paired up. Within one session, pairings are not repeated. +Visitors are prompted with two mobs and should decide which one they like better. After they choose, the "looser" is +replaced with a new candidate. In the background, an Elo-style rating system is keeping track of the individual matches. +The rating also determines the next candidate - similar ratings are paired up. Within one session, pairings are not repeated. ## Tech Stack @@ -27,10 +29,41 @@ Issues and Pull Requests are always welcome! ## Local Development -To develop locally, you need a PostgreSQL database and a PHP 8 interpreter. If you don't have a local web server, you can just use the built-in development server of PHP: `php -S localhost:8080 -t ./html/` +### With Docker + +The easiest way to develop locally is using Docker and Docker Compose. Just execute: + +```bash +cd local-dev +docker compose up --build +``` + +This will start a PostgreSQL server and a PHP dev container. The working directory is mounted in the container. +So, for PHP changes, you don't need to rebuild the container. However, for JS changes or new emojis (`emoji.css`) +you will either have to rebuild the container, or execute the build scripts manually (see "Without Docker") below. + +### Without Docker + +If you don't want to use Docker, you need a PostgreSQL database, a PHP 8 interpreter, and npm. +If you don't have a local web server, you can just use the built-in PHP development server: +`php -S localhost:8080 -t ./html/` As for configuration, just copy `./config.templ.php` to `./config.php`, fill out the values, and you are ready to go. The migrations are automatically applied with the first served request. -You will probably have to run `./bin/cron/updateData.php` to create the mob entries in the database and fetch the images. The other files in the `./bin/cron/` are not necessary for most development work, as they will just some cleanup and caching stuff for production. +To compile the JS, execute: + +```bash +cd resources/js +npm install +npm run build +``` + +This will also download Font Awesome. + +In order to download the emoji, execute `./bin/setup/fetch-emoji.sh`. +You'll have to repeat this whenever you add new emoji to `emoji.css`. + +You will also have to run `./bin/cron/updateData.php` to create the mob entries in the database and fetch the images. +The other files in the `./bin/cron/` are not necessary for most development work, as they will just some cleanup and caching stuff for production.