Browse Source

doc: Getting started documentation

Refs #39
Martin Bober 1 month ago
  1. 79
  2. BIN


@ -0,0 +1,79 @@
# Getting started with development for charXchange
This guide will get your development environment ready. It is assumed that your are somewhat familiar with [Docker][docker] and [docker-compose][docker-compose]
## Getting the Docker images needed for development
In order to get the servers needed for development running locally, you just need to use docker compose. In the root directory of this repository run:
sudo docker-compose up -d development
That should fetch all the needed services and build the `development` image containing this Rails application.
### Re-building the Rails application Docker images
If, in the future, you are changing something in the structure of the Rails application and its Ruby environment, especially the `Gemfile` and `Gemfile.lock` files, you will need to re-build the `development` and `test` images.
sudo docker-compose build development test
sudo docker-compose up -d development
## Initialize the Mumble server
For the mumble server to work correctly, especially to allow any user to create temporary channels (as the DiceBo does), you need to copy the server database to the docker container.
sudo docker-compose cp mumble-server.sqlite mumble:/data/
## Populate the database
Before you can start exploring the application, you'll have to populate the database a bit:
sudo docker-compose exec development bin/rake db:schema:load
Your development server is now ready to be used at [http://localhost:3000](http://localhost:3000).
## Creating the admin user
You now probably want to create user and give him administrative access. Go to [http://localhost:3000/signup](http://localhost:3000/signup) and fill out the registration form. You do not need to use your real email address here, but one you can remember, like ``. In this development environment, no emails are sent to the real world but to a locally running service called "Mailcatcher".
After you have filled out you registration form and go to the Mailcatcher at [http://localhost:1080/](http://localhost:1080/) to find the OTP token you need in order to complete the registration and activate your account.
### Become an administrator
One way to become an administrator is to use the *Interactive Rails Console*. To start the console run:
sudo docker-compose exec development rails c
In the Rails console run the following commands:
p = Player.last
p.is_admin = true
The first line loads the last created Player. The second line gives the local Player instance admin privileges and the third line writes the changes to the local Player instance to the database.
## Common development tasks
### Check the Rails output
Read the Rails server output (useful for debugging) by executing:
sudo docker-compose logs -t -f development
### Work with the database
If you want to interact with the database you can do so by using the following command:
mysql -h localhost --port 3001 -u root --password=charxchange charxchange
### Running tests
Most of the backend functionality is guarded by tests. To run those tests, you first need to bring up the test server.
sudo docker-compose up -d test
To actually run the test execute:
sudo docker-compose exec test rails test


Binary file not shown.