/barrelwisdom

Forked from https://github.com/CatClawed/barrelwisdom

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

barrelwisdom

A fansite for the long running Atelier series, as well as other Gust games.

https://barrelwisdom.com

barrel

To see how this is deployed and updated in a real world environment, see the deployment repo.

Docker usage

Most matters will be taken care of with:

docker compose build
docker compose up

But further backend setup is necessary.

Create docker/.env with the following format:

SECRET_KEY=50 rando character string of your choice goes here
DB_PASSWORD=
DB_USER=
DEBUG=1

DEBUG must be set to 0 in production environments.

In backend, you will also want to run:

ssh-keygen -t rsa -b 4096 -m PEM -f jwt-key

Finally, run the containers. To setup the database:

docker exec -it backend bash
python manage.py migrate

If you have data to load/dump:

python manage.py dumpdata --exclude=auth.permission --exclude=contenttypes --exclude=authtoken -o dump.json.gz
python manage.py dumpdata app_name -o dump.json.gz
python manage.py loaddata dump.json.gz

Update Postgres

Overall process: back up whole database, delete docker volume, then can start fresh.

Or, y'know, just make a db dump with django and let that do the work.

docker exec -it postgres psql -U [username] < dumpfile
docker cp dumpfile postgres:/home
# within new postgres container
psql -U [username] barrelwisdom < home/dumpfile

Build frontend

Be sure backend is running, as prerendering requires DB access.

docker exec -it frontend bash
npm run prerender

For the final docker image:

docker build -t frontend_prod -f Dockerfile.prod .
docker tag frontend_prod barrelwisdom/frontend:tag

Non-Docker Notes

Frontend

  1. Install NodeJS

Use latest LTS version. Install it from official site or use your package manager, such as Homebrew

  1. Install dependencies
npm install
# or
yarn install
  1. Install Angular CLI
npm install -g @angular/cli
  1. Common commands

After installing Angular CLI, ng commands will be available and you will be able to:

# Begin development
npm start

# Begin development in server-side rendering mode
npm run dev:ssr

# Production build
npm run prerender

Backend

  1. Install python and relevant tools

You need Python 3 or Miniconda with Python 3, your choice. Should be 3.11 and up.

# On Linux
sudo apt install python3-dev libpq-dev memcached git

# On Mac
brew install python@3.9 libmemcached
  1. Prepare a database

Install PostgreSQL. On MacOS I recommend usingPostgres.app since it's much easier to get it up and running.

  1. Use virtualenv or venv for current shell:
pip3 install virtualenv
virtualenv env
# or
python3 -m venv /your/path/here
source /your/path/here/bin/activate

Then install packages as listed in requirements.txt:

pip install -r requirements.txt
  1. Create secrets.json and jwt-key, same as in Docker section

  2. Common command usage

# Run this first. Copies existing migrations.
# Run it after using makemigrations as well
python manage.py migrate
# Run this when you make changes to the database
python manage.py makemigrations model_names_here

Get backend up and running

python manage.py runserver