DoK runs on version 13. Higher is probably fine. For working with Postgres I use a combination of my IDE's built in tools, PGAdmin and the command line.
DoK uses amazon corretto version 17. I'd recommend installing that version specifically.
https://docs.aws.amazon.com/corretto/latest/corretto-17-ug/what-is-corretto-17.html
I use Intellij as that's what I'm accustomed to and it works with Kotlin as well as TypeScript. If you don't install Intellij you'll also need to install Kotlin.
git clone https://github.com/CorayThan/decks-of-keyforge.git decks-of-keyforge
DoK needs a working database to run. However, you can download a working copy of the database from Amazon S3. First download the database dump:
https://dok-db-dumps.s3.us-west-2.amazonaws.com/dok-db.dump
Then make a folder at: /decks-of-keyforge/scripts/local-db-dump
and put the dump file there.
Then run the following commands from the project directory:
createdb -h localhost -U postgres -W keyswap
pg_restore -h localhost -U postgres --clean --if-exists --no-tablespaces --no-privileges --no-owner -d keyswap ./scripts/local-db-dump/dok-db.dump
Create a file /decks-of-keyforge/src/main/resources/appliaction-nocommit.yml
with the following contents:
jwt-secret: ${JWT_SECRET:7f310842a0b446a99eb3da6b8b99efa57f310842a0b446a99eb3da6b8b99efa5}
aws-secret-key: ${AWS_SECRET_KEY:fake}
patreon-secret-key: ${PATREON_SECRET:fake}
patreon-client-id: ${PATREON_CLIENT_ID:fake}
secret-api-key: fake
Certain features will not work when you develop locally, for example emails, patreon refreshing, and uploading deck verification pictures.
One time run:
Before you run the first time, and after you make changes to kotlin classes annotated with @GenerateTs
you need to
run:
./gradlew genSrc
To run the backend server run:
./gradlew bootRun
Install the dependencies for the frontend with:
cd ui
npm install
To run the frontend run:
cd ui
npm run start
When you try to login locally, remember that all passwords for all users will be 'password'.
The above should be all you need to get started to code and test a simple change to the Decks of KeyForge codebase.
Ensure you've revved the version in build.gradle.kts
then run:
./scripts/build-and-push.ps1
Login to AWS Elastic Beanstalk. Go to Upload and deploy. For file choose:
/docker/Dockerrun.aws.json
Would be nice to automate this so the service uploads newly found card images to S3.
Delete *.png
in /card-imgs/
. Uncomment line in RunOnStart. Run app. In /card-imgs/
run:
.\pngquant.exe --ext=.png --force 256 *.png
upload to S3 public with headers: Cache-Control: max-age=31536000
The remainder of this readme are notes I've taken over time about how to manage the project. These may be confusing and/or out of date.
making the db in RDS:
RDS create database
postgres
only enable free tier
20GB
name: keyswap-{env}
master username: coraythan
publicly accessible yes
choose default VPC-security group
db name: keyswap
3 day backups
connecting with pgadmin
maintenance db keyswap coraythan
This is out of date. It needs to be revised and then run again.
cd 'C:\Program Files\PostgreSQL\12\scripts\'
.\runpsql.bat
// server click enter
// database enter: keyswap
SET CLIENT_ENCODING TO 'utf8';
\COPY (select keyforge_id, name, expansion, house_names_string, sas_rating, synergy_rating, antisynergy_rating, aerc_score, amber_control, expected_amber, artifact_control, creature_control, efficiency, recursion, disruption, creature_protection, other, effective_power, raw_amber, action_count, upgrade_count, creature_count, power_level, chains, wins, losses, card_names from deck) to 'C:\Users\Coray\Downloads\dok-decks.csv' DELIMITER ',' CSV HEADER;
Find it in downloads
This is a useful postgresql query that will kill long running queries if DoK has deck searches going that will never end.
SELECT pg_cancel_backend(pg_stat_activity.pid)
from pg_stat_activity
WHERE (now() - pg_stat_activity.query_start) > interval '5 minutes' and state = 'active';
SELECT
pid,
now() - pg_stat_activity.query_start AS duration,
query,
state
FROM pg_stat_activity
WHERE (now() - pg_stat_activity.query_start) > interval '5 minutes'
LIMIT 10;
Go to profile for coraythan
Unlink and relink with buttons.
Go to: https://www.patreon.com/portal/registration/register-clients
Copy Creator's Access Token into the auth header
To update passwords run:
UPDATE key_user
SET password = '$2a$10$N3UlNyYNgndwUQgYos1hq.jwIL.K4utk14pYtZki2Otc3Ii7WdvuW';
The password for all users will be "password".