DofusLab is an open source set builder for players of the French MMO Dofus, where you can experiment with your equipment.
Written using TypeScript and Python 3.
Please come give us a try at https://dofuslab.io!
Project setup (manual)
$ sudo echo '127.0.0.1 dev.localhost' >> /etc/hosts
$ cp client/.env.dist client/.env && cp server/.env.dist server/.env
$ postgres -D /usr/local/var/postgres
$ redis-server
Alternative: Start postgres and redis with Homebrew
$ brew services start postgresql; brew services start redis
$ psql
$ CREATE DATABASE dofuslab;
$ \c dofuslab
$ CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
$ exit
Replace [USER]
with your postgres username.
$ sed -i '' 's/postgres:password/[USER]:password/g' server/.env
$ python3 -m venv venv
$ source venv/bin/activate
$ cd server
$ pip install -r requirements.txt
flask db upgrade
python -m oneoff.database_setup
python -m oneoff.update_image_urls
$ flask run
$ yarn
$ cd client
$ yarn
$ yarn dev
Open http://dev.localhost:3000/ and test away!
Project setup (docker)
To get started, you'll need to install Docker Desktop, and optionally (but highly recommended) Tilt.
Note that you may need to configure your git client to check out "as-is" to avoid converting scripts to CRLF, which will result in errors like:
dofuslab@ac1658cacb7a:~/oneoff$ ./setup_db.sh
bash: ./setup_db.sh: /bin/sh^M: bad interpreter: No such file or directory
Once you have Docker Desktop and Tilt installed, you can run the Dofuslab environment by simply opening a terminal to the project directory, and running:
$ tilt up
This should result in some messages that look like:
$ tilt up
Tilt started on http://localhost:10350/
v0.30.7, built 2022-08-12
(space) to open the browser
(s) to stream logs (--stream=true)
(t) to open legacy terminal mode (--legacy=true)
(ctrl-c) to exit
At this point, you can press the spacebar to open Tilt in the browser to see service status and logs (or s
to stream logs, etc). Dofuslab should now be building, and doing most of the steps in the manual setup section automatically.
It'll probably take a few minutes to build the containers the first time, due to how big the client and server containers are.
If you only have Docker and aren't using Tilt:
$ docker compose up -d
Once you have the docker compose/tilt environment running, you need to get the database populated.
You can do this several ways. You can either run:
$ docker compose exec server /home/dofuslab/oneoff/setup_db.sh
Note that re-running this action can create duplicate items in the database, so just running it once is recommended. If you mess up your database, it's simple to reinitialize it. The simplest way is to bring your environment down (tilt down
), and remove the postgres volume:
$ docker volume rm dofuslab_pgdata
Once you have your database populated, you should be able to access your development Dofuslab instance at http://localhost:3000/.
Making changes (manual)
After making changes to the database schema (e.g. server/app/database/model_*.py
) generate a new migration.
$ cd server
$ flask db migrate
Check the newly generated migration and make any necessary changes with your preferred text editor (vim, nano, emacs, Visual Studio Code, etc)
$ vim server/app/migrations/versions/[SOME_HASH].py
Apply your new migration.
$ flask db upgrade
After making any changes to GraphQL queries or mutations (client/graphql/*
), or the GraphQL schema (server/app/schema.py
), generate TypeScript types.
$ cd client/
$ yarn apollo-codegen
To add any new user-facing strings client-side, add the key in the EN locale files first (/client/public/static/locales/en/*
).
$ cd client/
$ yarn sync-i18n
When adding any user-facing strings in the backend, update all the messages.po
files with the new strings.
$ cd server/
$ make update-translations
Check the translations and make any necessary changes with your preferred text editor, then compile the translations.
$ make compile-translations
Run make freeze
to update requirements.txt (https://stackoverflow.com/questions/39577984/what-is-pkg-resources-0-0-0-in-output-of-pip-freeze-command)
After all changes to the .json files inside server/app/database/data
are made, it will be necessary to sync the database in order to include them.
$ cd server
$ python -m oneoff.sync_item
Making changes (Tilt)
For most things, Tilt should automatically update when files are changed. If things don't update correctly, you can docker compose exec
scripts on the appropriate containers to update things. For instance:
$ cd server
$ flask db migrate
...becomes:
$ docker compose exec server flask db migrate
That said, these updates should (for the most part) happen automatically!
As of time of this writing, it will be necessary to sync items (and such) to the database when changes are made to those json files. I recommend having a shell opened in the server container:
$ docker compose exec -it server /bin/bash
...and following the sync instructions in the "manual" section. For example:
$ python -m oneoff.sync_item