Skip to content
JulienGaumez edited this page Apr 7, 2022 · 33 revisions

Cryptopus Development 👩🏽‍💻

We're glad you want to setup your machine for cryptopus development 💃

System Requirements

You need to have Docker and docker-compose installed on your computer. The free Docker Community Edition (CE) works perfectly fine. Make sure your user is part of the docker group:

usermod -a -G docker $USER

Additionally you need git to be installed and configured.

🐧 This manual focuses on Linux/Ubuntu. Cryptopus development also runs on other plattforms with some adjustments.

Windows users

If you're on Windows you should be able to Download Ubuntu from Microsoft Store. Note that you need to enable Subsystem for Linux and virtual machine platform in your Windows features.
Then you can open Ubuntu and follow the manual using the Ubuntu console.
When you finished use your Windows IDE and open the cryptopus folder that's located in your Linux subsystem -> Ubuntu and start developing.
If this doesn't work you can always use a VM.

Preparation

First you need to clone this repository:

mkdir -p ~/git/ && cd ~/git/
git clone https://github.com/puzzle/cryptopus.git && cd ~/git/cryptopus

⚡ If your user id is not 1000 (run id -u to check), you need to export this as env variable: export UID=$UID before running any of the further commands. Maybe you want to add this to your bashrc.

Start Development Containers

First compile frontend, mainly to make all assets available to rails server.

docker-compose run ember yarn build --prod
docker-compose run rails rails db:setup
docker-compose run rails ./bin/prepare-frontend.sh

If you have gcloud Problems with the above commands run this to properly set the python version that GCloud uses: export CLOUDSDK_PYTHON=python2

To start the Cryptopus application, run the following command in your shell:

docker-compose up -d

⚡ This will also install all required gems and seed the database, which takes some time to complete if it's executed the first time. You can follow the progress using docker-compose logs --follow rails (exit with Ctrl+C).

After the startup has completed (once you see Listening on tcp://0.0.0.0:3000 in the logs), make sure all services are up and running:

docker-compose ps

This should look something like this:

      Name                     Command               State                                                              Ports                                                            
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
cryptopus_ember_1   ember-entrypoint ember serve     Up      0.0.0.0:4200->4200/tcp,:::4200->4200/tcp, 0.0.0.0:7020->7020/tcp,:::7020->7020/tcp, 0.0.0.0:7357->7357/tcp,:::7357->7357/tcp
cryptopus_rails_1   rails-entrypoint rails ser ...   Up      0.0.0.0:3000->3000/tcp,:::3000->3000/tcp 

Access the web application by browser: http://localhost:3000 and log in using alice and password password.

Development

Start developing by editing files in this repository locally with your prefered editor.

Running rails tasks, console

For running tests, executing tasks like rails routes or starting the rails console in development environment, run the following command:

docker-compose exec rails bash

Tests

Development Testing for executing automated unit, controller, system ... tests

HTTP request debugging with pry

For debugging with pry during a HTTP request, you can attach to the running docker container:

docker attach $(docker-compose ps | grep _rails_1 | cut -d ' ' -f 1)

For detaching after debugging, you use CTRL+p followed by CTRL+q

Shutdown

🍺 finished work ? execute docker-compose down to shut down all running containers

Updating Images

When the images of this project change, execute the following command to update them locally:

docker-compose build --no-cache

Getting started

To get familiar with the technology Cryptopus is using, walk your-self through any of the following tutorials:

Frontend ⚡

If you're not already familiar with emberjs, look out for any getting started guides or use one of the following:

To contribute for the frontend, it is recommended that you've preinstalled the Ember Inspector for Chrome or for Firefox.

You can also take a look into the Ember CLI which makes creating components and running tests, etc... a lot easier.

Backend 🏢

A good way to familiarize yourself with Rails, is to carefully work through this tutorial:

Development Process

Before a Pull Request

  1. Write tests (TDD)
  2. Implementation
  3. Remove all console outputs
  4. Remove unnecessary comments
  5. Remove or translate German comments
  6. Remove dead code
  7. Run Rubocop (code style check) rake rubocop
  8. Run all Tests rake
  9. Manual testing ok?
  10. Update CHANGELOG.md
  11. Comply with Git Workflow (Commit/Push/Rebase)
  12. Travis CI green?

Before Release

  1. Check CHANGELOG.md
  2. Check VERSION.md
  3. Tag the new release with git tag ...
  4. Merge into stable branch
  5. Update VERSION.md on master branch