Skip to content

Latest commit

 

History

History
167 lines (98 loc) · 6.9 KB

README.md

File metadata and controls

167 lines (98 loc) · 6.9 KB

plemiona-planer

Codecov GitHub tests stage_image_push.yml latest_image_push.yml

Official Site and Discord

Discord channel: discord.gg/g5pcsCteCT

Production server: plemiona-planer.pl

Stage environment: stg.plemiona-planer.pl

Test coverage ~85%, see Codecov raport

Table of contents

Development

If you want to run it in development you will need

In your favourite folder e.g. Desktop:

git clone https://github.com/rafsaf/Tribal-Wars-Planer.git
cd Tribal-Wars-Planer

Then create file .env in Tribal-Wars-Planer from template file .env.example

Then run

poetry install

# it will be default create virtualenv in ~.cache/pypoetry/virutalenvs/tribal-wars-planer-asod(some random signs)
# You need to activate it.
# Honestly, you can also use just python3.12 -m venv .venv and run pip install -r requirements-dev.txt but above is prefered way
pre-commit install

# adds pre-commit stuff

Run database with docker and then python dev server

docker-compose up -d postgres_dev
# This set up db container

bash scripts/initial.sh
# migrations, creates admin/admin superuser, creates media and prometheus dirs, creates game servers

python manage.py runserver
# Runs development server at localhost:8000

To run tests with coverage report

pytest

To run makemessages/compilemessages (the project is in English, every string is then translated to Polish)

# every machine - using dockerfiles
docker compose -f docker-compose.translation.yml run --rm trans

Dockerfile reference

This project maintains one docker images, the same one for server and for scheduling tasks. It's hosted via dockerhub and supports arm64 and amd64 architectures.

NOTE, from 3.0.0 images support both linux/amd64 and linux/arm64 architectures.

NOTE, from 4.0.0 image twp-cronjobs is deprecated, please update for support. Cronjobs tasks are now runned from the main image.

TWP-server image

TWP-server image on dockerhub

rafsaf/twp-server:latest

Note, there are also other tags like stage or stable, but latest should be prefered choice.

Contains TWP Django server based on python:3.13.0 docker image, with nginx/1.18.0 + uwsgi for webserver stack and tiny Python cron-like lib schedule for tasks and many more open source software.

Environment variables:

SECRET_KEY - required - app secret key

DEBUG - optional - debug boolean, defaults to False

DJANGO_SUPERUSER_USERNAME - optional - first superuser username, defaults to admin

DJANGO_SUPERUSER_PASSWORD - optional - first superuser password, defaults to admin

DJANGO_SUPERUSER_EMAIL - optional - first superuser email, defaults to [email protected]

MAIN_DOMAIN - optional - main domain used, defaults to localhost

SUB_DOMAIN - optional - sub domain used, defaults to empty string

CSRF_TRUSTED_ORIGINS - optional - list of domain that can perform POST and other unsafe requests to the app eg. https://domain1,https://domain2,http://domain3, see django docs, defaults to http://localhost:8000,http://localhost:7999

POSTGRES_NAME - optional - postgres database name, defaults to postgres

POSTGRES_USER - optional - postgres database user, defaults to postgres

POSTGRES_PASSWORD - optional - postgres database password, defaults to postgres

POSTGRES_HOST - optional - postgres database host, defaults to postgres

POSTGRES_PORT - optional - postgres database port, defaults to 5432

DATABASE_SSL_MODE_ON - optional - Require TLS/SSL when connecting to the database, defaults to False

DEFAULT_FROM_EMAIL - optional - email of site owner, used to send emails on errors and certs expiration, defaults to [email protected]

STRIPE_PUBLISHABLE_KEY - optional - stripe public key, defaults to empty string

STRIPE_SECRET_KEY - optional - stripe secret key, defaults to empty string

STRIPE_ENDPOINT_SECRET - optional - stripe endpoint, defaults to empty string

EMAIL_BACKEND - optional - email backend, refer to django docs, defaults to django.core.mail.backends.console.EmailBackend

AWS_ACCESS_KEY_ID - optional - AWS SES account key id, defaults to empty string

AWS_SECRET_ACCESS_KEY - optional - AWS SES account secret, defaults to empty string

AWS_SES_REGION_NAME - optional - AWS SES region, defaults to empty string

AWS_SES_REGION_ENDPOINT - optional - AWS SES region endpoint, defaults to empty string

METRICS_EXPORT_ENDPOINT_SECRET - optional - secret that allow (prometheus scrapers) access to domain.com/api/metrics/?token=..., defaults to secret

UWSGI_PROCESSES - optional - number of uwsgi processes spawned in the container, defaults to 1

PREMIUM_ACCOUNT_VALIDATION_ON - optional - is premium account required to create more targets, defaults to False

PREMIUM_ACCOUNT_MAX_TARGETS_FREE - optional - max targets allowed without premium account, defaults to 25

REGISTRATION_OPEN - optional - is registration on site allowed, defaults to True

JOB_LIFETIME_MAX_SECS - optional - Stops cronjob function after JOB_LIFETIME_MAX_SECS seconds, defaults to 0 and that means it will not stop ever. If number is greater than 0, it must be also greater or equal to 120 (2 min).

JOB_MIN_INTERVAL - optional - minimal time when database info about villages, players, worlds will be updated in minutes, defaults to 10

JOB_MAX_INTERVAL - optional - maximal time when database info about villages, players, worlds will be updated in minutes, defautls to 15