Giter Club home page Giter Club logo

fwstats-pure's Introduction

FWSTATS ๐Ÿš€

Statistics website for the worlds ActionFreewar and ChaosFreewar in the browser game freewar.de.

TechStack

PHP 8.2, Bulma CSS, SQLite, Vanilla JS, Apache httpd with mod_php. All of this is shipped as a single docker image.

Quality assurance

  • PHPUnit: Unit tests and application tests against a database
  • PHPStan: Level max, 100% type coverage, strict rules + own custom rules
  • PHP-CS-Fixer: PSR-12

Deployment strategy

Creating a new tag and pushing this tag to GitHub runs a GitHub action which builds a new container image, tags the image with the new tag and pushes this image to the GitHub container registry. After this I will just stop the running container on my server and start a new one. No rolling update needed, not like I have tons of users. ๐Ÿคทโ€โ™‚๏ธ

Check the newest docker image here.

Local setup

1. Start the docker container

docker-compose up -d

2. Install composer packages

Use the docker container to install composer packages. This way it's not important which PHP version you have installed locally, and you do not run into any errors.

docker-compose exec php composer install

3. Load migrations

docker-compose exec php php bin/console.php app:database-migration

4. Load fixtures

docker-compose exec php php bin/console.php app:database-fixture

5. Finished

Open your browser and visit http://localhost:8080. A test account with username admin and password Password12345 was also created for you.

First deployment

1. Create a named volume

docker volume create fwstats-prod

2. Run the docker image

docker run --detach --volume fwstats-prod:/var/www/html/data/database --publish 8888:80 --name fwstats-prod ghcr.io/jesperbeisner/fwstats:latest

3. Run the migrations

docker exec fwstats-prod php bin/console.php app:database-migration

4. Run one cronjob for everything every 5 minutes

*/5 * * * * docker exec fwstats-prod php bin/console.php app:run > /dev/null 2>&1 

4 1/2. Use the /cronjob endpoint

In addition to the cronjob, there is also a cronjob endpoint (/cronjob) that does the same thing as the normal cronjob. You need to send a post request with your bearer token which you can find in the admin panel when you log in. For this to run reliably, a service such as cron-job.org can be used. Just call the endpoint every 5 minutes and that's it.

5. Finished!

Point your reverse proxy on your published port (In this example 8888) and visit your domain. You can log in with the automatically created credentials admin as username and Password12345 as password. Change the password and e-mail after your first login. That's it, you're done. ๐Ÿš€

Additional deployments

1. Remove your running container

docker rm -f fwstats-prod

2. Remove the old image

docker rmi -f ghcr.io/jesperbeisner/fwstats:latest

3. Start a new container with the new image

docker run --detach --volume fwstats-prod:/var/www/html/data/database --publish 8888:80 --name fwstats-prod ghcr.io/jesperbeisner/fwstats:latest

4. Run the migrations

docker exec fwstats-prod php bin/console.php app:database-migration

5. Finished

Upgrade is done. You are now running the newest version. ๐Ÿš€

fwstats-pure's People

Contributors

jesperbeisner avatar

Watchers

Kostas Georgiou avatar  avatar

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.