These instructions will get you a runnable docker image where you can test the complete chaos environment on your own chaos fork.
First you'll need to set up a Personal Access Token (PAT). Go to your Github Personal Access Token settings. PATs are like passwords, only more secure, because you can enable limited actions for them, and they're easy to revoke if they are compromised. Click "Generate new token" at the top right. For your Token description, enter "chaos test". Then you'll need to check the following options:
- repo
- public_repo ✓
- user
- user:follow ✓
When you're done with that, click the green "Generate Token" at the bottom. And copy the token it displays on the screen. Be sure to copy it now, since you won't see it again. If you lose it, you'll have to regenerate another one.
Put your PAT in the file github_pat.secret
in the root of the chaos repo so
you don't lose it. Be sure not to commit this file and share it with the world
:)
Navigate to dev/docker/
.
Then you can build with docker-compose build
but this is not mandatory (up will do it for you).
Or you can run bash build.sh
instead.
For Windows, be sure to have docker started, then you can run build.bat
.
This will run the Dockerfile and produce your docker image with the name
chaos
.
If you want to build on a Raspberry Pi run bash build.sh -rpi
.
Make sure you're in dev/docker/
.
You can simply run docker-compose up chaos
.
Or you can run with bash run.sh
or run.bat
.
To debug your code, you probably want to drop into a debugger via import pdb; pdb.set_trace()
. To do this, you need to run docker-compose run debug
, will
run the chaos container in interactive mode, and without starting under
supervisor. Starting chaos this way will let you
interact with the debugger.
Make sure you're in dev/docker/
.
You can simply run docker-compose up tests
.
Or you can also run tests with bash test.sh
or test.bat
.
The repo dir exists as a mounted data
volume
inside the your running docker container. What this means is that files created
or edited inside the container, in /root/workspace/chaos
-- will exist
outside the container, and vice versa.
- Edit your files locally and make your changes.
- Run
bash run.sh
. - Watch chaos startup in your terminal, tailing its error and stdout logs.
- Make some dummy pull requests or whatever on your github fork.
- Watch chaos interact with your github fork, as if it was the main
chaosbot/chaos
repo. - Open a PR to
chaosbot/chaos
once you're convinced your changes work.
The environment inside the docker image should be very very close to what's actually on production. As such, any servers started by chaos inside the container may be accessed from your host machine. At the time of this writing, there are currently two servers running:
- 80 => 8082 - python server/server.py webserver
- 8081 => 8081 - nginx static directory to
/var/log/supervisor