Skip to content

Commit 7119491

Browse files
authored
performance boost with meinheld and flask-minify, fixes, admin can now change user password (#76)
1 parent 1f5634e commit 7119491

29 files changed

+168
-93
lines changed

.dockerignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,11 @@ venv/
44
.vscode/
55
*.db
66
.idea/
7-
.github/
7+
.github/
8+
.lgtm.yml
9+
Procfile
10+
app.json
11+
setup.cfg
12+
runtime.txt
13+
migrations/
14+
*.test.py

.env

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
##### RTB-CTF-Framework environment variables configuration #####
2+
3+
# Generate a psuedo-random secret with: ..
4+
#... python3 -c "print(__import__('secrets').token_hex(16))"
5+
SECRET_KEY=DontForgetToChangeMe
6+
# If serving over HTTPS, mark this True for added security
7+
SSL_ENABLED=False
8+
# about 2 x number of CPU cores
9+
WORKERS=4
10+
# Choose a strong password for administrator!
11+
ADMIN_PASS=admin
12+
# These values should be the same as specified in .env_postgres
13+
DB_USER=user
14+
DB_PASSWORD=password
15+
DB_NAME=rtbctf
16+
# Don't change
17+
DB_PORT=5432

.env_postgres

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Please choose a strong password !!
2+
3+
POSTGRES_USER=user
4+
POSTGRES_PASSWORD=password
5+
POSTGRES_DB=rtbctf
File renamed without changes.
File renamed without changes.

INSTALLATION.md renamed to .github/INSTALLATION.md

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
### Requirements
44

5-
* Tested on `Python 3.8.2`
5+
* Tested on `Python 3.8.3`
66
* Python Packages: [`src/requirements.txt`](src/requirements.txt).
77
* OS Packages: PostgreSQL version 11 or greater, `libpq-dev`, `python3-dev` packages. Please refer [here](https://tutorials.technology/solved_errors/9-Error-pg_config-executable-not-found.html).
88

9-
### Build locally and run
9+
### Build locally and run (Development)
1010

1111
1. Git clone the repo and `cd ` into it
1212

@@ -22,20 +22,33 @@ $ source venv/bin/activate
2222
$ cd src/
2323
```
2424

25-
3. With `virtual environment` activated, install requirements, init db and run !
25+
3. With `virtual environment` activated, install requirements, init db,
2626

2727
```bash
2828
[venv]$ pip install -r requirements.txt
29-
[venv]$ python create_db.py # Only required on first run
30-
[venv]$ python run.py
29+
[venv]$ chmod +x init_db.sh && ./init_db.sh # Only required on first run
3130
```
3231

33-
> Warning: If you make any change to [`config.py`](https://github.com/abs0lut3pwn4g3/RTB-CTF-Framework/blob/master/src/FlaskRTBCTF/config.py) logging/config class/score settings. It's highly recommended to create a new DB instance.
32+
4. Now we can run our application,
3433

35-
### Docker
34+
- For development server,
3635

37-
> Note: The Docker support is not tested for production yet. It's recommended to use Heroku for production.
36+
```bash
37+
[venv]$ python run.py
38+
```
3839

39-
```bash
40-
$ docker-compose up
41-
```
40+
- Production server
41+
42+
```bash
43+
[venv]$ ./runserver.sh
44+
```
45+
46+
### Docker (Production)
47+
48+
1. Define certain environment variables present in files `.env` and `.env_postgres`.
49+
50+
2. After having configured these environment variables, just execute,
51+
52+
```bash
53+
$ docker-compose up
54+
```

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
__pycache__/
22
venv/
3+
migrations/
34
*.pyc
45
.vscode/
56
*.db

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
FROM python:3.8.2-alpine3.11
1+
FROM python:3.8.3-alpine3.12
22

3-
MAINTAINER eshaan7bansal@gmail.com
3+
LABEL maintainer="eshaan7bansal@gmail.com"
44

55
# Env
66
RUN export DATABASE_URL="postgres://${DB_USER}:${DB_PASSWORD}@postgres:${DB_PORT}/${DB_NAME}" \
@@ -16,8 +16,8 @@ RUN adduser --shell /sbin/login www-data -DH
1616
# Install RTB-CTF-Framework
1717
WORKDIR /usr/src/app
1818
COPY src ./
19-
RUN pip install --no-cache-dir -r requirements.txt \
20-
&& chown -R www-data ./
19+
RUN chown -R www-data ./
20+
RUN pip install --no-cache-dir -r requirements.txt
2121

2222
USER www-data
2323

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ The 100 second elevator-pitch is that: A Capture The Flag framework; one that is
4444

4545
## Build locally
4646

47-
Please see [INSTALLATION.md](INSTALLATION.md).
47+
Please see [INSTALLATION.md](.github/INSTALLATION.md).
4848

4949
## Host a customized CTF with Heroku for free in under a minute
5050

@@ -83,7 +83,7 @@ The main purpose of this project is to serve as a scoring engine and CTF manager
8383

8484
- [#rtb-ctf-framework on slack](https://rtb-ctf-framework.slack.com)
8585

86-
Please refer to [CONTRIBUTING.md](CONTRIBUTING.md)
86+
Please refer to [CONTRIBUTING.md](.github/CONTRIBUTING.md)
8787

8888

8989
## Live Demo

app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
}
3434
},
3535
"scripts": {
36-
"postdeploy": "python3 src/create_db.py"
36+
"postdeploy": "bash src/init_db.sh"
3737
}
3838
}

0 commit comments

Comments
 (0)