Documentation about config files

This commit is contained in:
Michael Zhang 2020-11-26 03:50:35 -06:00
parent 3051447cce
commit 51420c3e14
No known key found for this signature in database
GPG Key ID: BDA47A31A3C8EE6B
10 changed files with 64 additions and 37 deletions

9
contest.dhall Normal file
View File

@ -0,0 +1,9 @@
let Competition = ./schema/competition.dhall in
Competition.Config :: {
startDate = "2021-01-01T00:00:00+00:00",
endDate = "2021-01-08T00:00:00+00:00",
mailer = Competition.Mailer.Smtp Competition.Smtp :: {
host = "easyctf.com",
},
}

7
deploy.dhall Normal file
View File

@ -0,0 +1,7 @@
let Deploy = ./schema/deploy.dhall in
Deploy.Config :: {
adminEmail = "team@easyctf.com",
environment = Deploy.Environment.Development,
secretKey = "asdf",
}

View File

@ -22,6 +22,9 @@ services:
links:
- db
- redis
volumes:
- "./contest.dhall:/contest.dhall"
- "./deploy.dhall:/deploy.dhall"
environment:
- "SECRET_KEY=${SECRET_KEY}"
- "ADMIN_EMAIL=${ADMIN_EMAIL}"

View File

@ -1,3 +1,3 @@
# Summary
- [Chapter 1](./chapter_1.md)
- [Configuration](./configuration.md)

View File

@ -1 +0,0 @@
# Chapter 1

24
docs/src/configuration.md Normal file
View File

@ -0,0 +1,24 @@
# Configuration
LibreCTF is configured using the language [Dhall][1]. It introduces many
type-safety-related benefits. Before running, make sure the config files
`deploy.dhall` and `contest.dhall` live in the same directory as
`docker-compose.yml`. The docker compose config will mount these dhall files
into the volume when it starts the application.
There's 2 sets of configuration:
- the deployment config, which is loaded once when the platform is started. The
platform must be restarted in order to reload this config
- the contest config, which can be freely hot-reloaded as the platform is
running
## Deployment Config
The schema for the deployment config can be found in `./schema/deploy.dhall`.
## Contest Config
The schema for the deployment config can be found in `./schema/contest.dhall`.
[1]: https://dhall-lang.org/

View File

@ -1,18 +0,0 @@
let Competition = ./schema/competition.dhall in
let Deploy = ./schema/deploy.dhall in
let competition = Competition.Config :: {
startDate = "2021-01-01T00:00:00+00:00",
endDate = "2021-01-08T00:00:00+00:00",
mailer = Competition.Mailer.Smtp Competition.Smtp :: {
host = "easyctf.com",
},
} in
let deploy = Deploy.Config :: {
adminEmail = "team@easyctf.com",
environment = Deploy.Environment.Development,
secretKey = "asdf",
} in
{ competition, deploy }

View File

@ -39,6 +39,7 @@ raven = {extras = ["flask"], version = "*"}
redis = "*"
requests = "*"
wtforms = "*"
dhall = "*"
[dev-packages]
pyls = "*"

20
server/Pipfile.lock generated
View File

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "871e1f26eb1c2dec8d2bdb0eaacd240a51ac120d69244590115999a1a0fbfe1a"
"sha256": "2a78c178c6db928e790ab25a066f16eed8c12151e47ae8c277d5ce8c61c9bb82"
},
"pipfile-spec": 6,
"requires": {
@ -223,6 +223,24 @@
],
"version": "==4.4.2"
},
"dhall": {
"hashes": [
"sha256:07b56ec88b35021e4d51a0f3a44ab6ffb501b0525f3c00f66847bdce7d76428d",
"sha256:229ed80385c9d686efe26f22961a5808446dfb3cef9318b4164c11564bb57cb4",
"sha256:2338ea6370a52fc392da4437f0c51a50b8006a90a25d0d283454c1fca28dfa51",
"sha256:366f2eaeeaf1df3a3d29b4ff4692580efc4c7f182d933bd844f7767536fe738f",
"sha256:420203a8bb6b7b1c15dfbe6f2469b8b673bab01eda26bd7af212f6b2160633bc",
"sha256:5e924f562451776b6ed7849e382fe81d90f176fe8ae9cc4217a18e2002a920ce",
"sha256:6ecdda5eb31077753b694c702c4778d7ee0f5b3e3e9937b94fa635b7881dc90a",
"sha256:8d3b43743f10d32a063045bc7bbe968252b7a1a1ce5685be8e1d1d7e63e79673",
"sha256:9ca4c30a89eef974d2a94ba30c93947e2fa375233e48006e4adfed7d99ffb043",
"sha256:e5961e979fa75db85935f3f78a40342541f68d69953a3159ec8e6c56518beebd",
"sha256:f25dd00ac06d03ed54745379a0ae08c4d2d391ef1ab06fbea48fdbad62039869",
"sha256:f514456a2b747106916b8aa67302a9c356ba94f22bdffaa54a65f0c30e7f5d16"
],
"index": "pypi",
"version": "==0.1.5"
},
"dnspython": {
"hashes": [
"sha256:044af09374469c3a39eeea1a146e8cac27daec951f1f1f157b1962fc7cb9d1b7",

View File

@ -1,16 +0,0 @@
[Unit]
Description=easyctf web server
After=network.target
[Service]
EnvironmentFile=/var/easyctf/env
PIDFile=/run/easyctf/pid
User=root
WorkingDirectory=$PROJECT_DIRECTORY
ExecStart=$PROJECT_DIRECTORY/entrypoint.sh
ExecReload=$KILL -s HUP \$MAINPID
ExecStop=$KILL -s TERM \$MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target