This is a web backend application that has the capability to spawn on demand docker containers.
It is created for Capture The Flag events (CTF's) where the users needs to have their own container. Example a web application where they need to mess with the database or get root access to the system.
The backend contains three main parts:
- Django web server
- Docker container manager
- Træfik reverse proxy
The users can create and login to their accounts using discord login.
The system app is the "logical" part of the program. Here the endpoints for creating and managing the containers are located.
Admin stuff
docker_manager.py
is the main file for managing the docker containers.
images/
is the directory where the docker images are stored.
images/program_handler.py
is the file that handles the images.
Træfik is a reverse proxy that is used to route the traffic to the correct container.
DISCORD_REDIRECT_URI needs to be the same as the backend domain.
Example if backend domain is backend-ctf.tinius.dev
The redirect url needs to be https://backend-ctf.tinius.dev/accounts/discord/
- Clone the repository
- Setup discord bot here
- Configure the
.env
file. - Update the certificates in
certs/
with your own certificates.certs/priv.key
andcerts/pub.crt
- Update the line
- "traefik.http.routers.ctf_app.rule=Host(`backend-ctf.tinius.dev`)"
indocker-compose.yml
needs to be the same domain as in the .env file for backend. - Add wildcard to your domain. Example
backend-ctf.tinius.dev
and*.backend-ctf.tinius.dev
Check out Images docs
It may take some time before the backend is up as it has to build the images.
docker compose build --no-cache
docker compose up -d
Gracefull shutdown has not been implemented yet. So you have to stop the containers manually if you kil the docker compose.
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker network rm $(docker network ls -q)
docker rmi $(docker images -q)
- Add ability to pull and use images directly from docker hub