-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from abs0lut3pwn4g3/challenges-dev
merge "challenges-dev" into "gssoc20-dev"
- Loading branch information
Showing
53 changed files
with
2,043 additions
and
787 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,28 @@ | ||
FROM python:3 | ||
FROM python:3.8.2-alpine3.11 | ||
|
||
MAINTAINER [email protected] | ||
|
||
# Env | ||
RUN export DATABASE_URL="postgres://${DB_USER}:${DB_PASSWORD}@postgres:${DB_PORT}/${DB_NAME}" \ | ||
&& export REDIS_URL="redis://redis:6379/0" | ||
|
||
# update and install packages | ||
RUN apk update \ | ||
&& apk add libpq postgresql-dev \ | ||
&& apk add build-base \ | ||
&& apk add --no-cache git libssl1.1 g++ make libffi-dev | ||
|
||
# Add a new low-privileged user | ||
RUN adduser --shell /sbin/login www-data -DH | ||
|
||
# Install RTB-CTF-Framework | ||
WORKDIR /usr/src/app | ||
COPY src ./ | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
EXPOSE 8080 | ||
RUN chown -R 1001:1001 . | ||
USER 1001 | ||
RUN pip install --no-cache-dir -r requirements.txt \ | ||
&& chown -R www-data ./ | ||
|
||
USER www-data | ||
|
||
EXPOSE 8000 | ||
RUN chmod +x /usr/src/app/docker-entrypoint.sh | ||
ENTRYPOINT [ "/usr/src/app/docker-entrypoint.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,55 @@ | ||
version: "3" | ||
|
||
services: | ||
rtbd: | ||
rtbctf: | ||
build: . | ||
container_name: rtb_gunicorn | ||
restart: unless-stopped | ||
ports: | ||
- 80:8080 | ||
restart: unless-stopped | ||
- "80:8000" | ||
expose: | ||
- 8000 | ||
environment: | ||
- DEBUG=False | ||
- SECRET_KEY=changeme | ||
- DB_USER=eshaan | ||
- DB_PASSWORD=eshaan | ||
- DB_NAME=rtbctf | ||
- DB_PORT=5432 | ||
- WORKERS=8 | ||
- ADMIN_PASS=admin | ||
depends_on: | ||
- postgres | ||
- redis | ||
|
||
postgres: | ||
image: library/postgres:12.1-alpine | ||
container_name: rtb_postgres | ||
restart: unless-stopped | ||
expose: | ||
- "5432" | ||
environment: | ||
- POSTGRES_USER=eshaan | ||
- POSTGRES_PASSWORD=eshaan | ||
- POSTGRES_DB=rtbctf | ||
|
||
redis: | ||
image: redis:6.0-rc4-alpine | ||
container_name: rtb_redis | ||
restart: unless-stopped | ||
expose: | ||
- "6379" | ||
|
||
|
||
# nginx: | ||
# image: library/nginx:1.16.1-alpine | ||
# container_name: rtb_nginx | ||
# restart: unless-stopped | ||
# hostname: nginx | ||
# volumes: | ||
# - ./rtb_nginx_http:/etc/nginx/conf.d/default.conf | ||
# ports: | ||
# - "80:80" | ||
# - "443:443" | ||
# depends_on: | ||
# - rtbctf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# the upstream component nginx needs to connect to | ||
upstream flask { | ||
server rtbctf:8000 fail_timeout=30s; | ||
} | ||
|
||
|
||
server { | ||
listen 80; | ||
|
||
server_name rtbctf.com; | ||
|
||
location / { | ||
proxy_pass http://localhost:8000/ | ||
} | ||
|
||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,42 @@ | ||
from flask import Flask | ||
from flask_sqlalchemy import SQLAlchemy | ||
from flask_bcrypt import Bcrypt | ||
from flask_login import LoginManager | ||
from flask_admin import Admin | ||
from flask_mail import Mail | ||
from FlaskRTBCTF.config import Config, LOGGING | ||
import os | ||
|
||
db = SQLAlchemy() | ||
bcrypt = Bcrypt() | ||
login_manager = LoginManager() | ||
admin_manager = Admin() | ||
login_manager.login_view = "users.login" | ||
login_manager.login_message_category = "info" | ||
mail = Mail() | ||
from flask import Flask | ||
|
||
from FlaskRTBCTF.config import Config | ||
from FlaskRTBCTF.utils import ( | ||
db, | ||
bcrypt, | ||
cache, | ||
login_manager, | ||
admin_manager, | ||
mail, | ||
inject_app_context, | ||
) | ||
from FlaskRTBCTF.users.routes import users | ||
from FlaskRTBCTF.ctf.routes import ctf | ||
from FlaskRTBCTF.main.routes import main | ||
|
||
|
||
_blueprints = (users, ctf, main) | ||
|
||
_extensions = (db, bcrypt, cache, login_manager, admin_manager, mail) | ||
|
||
|
||
def create_app(config_class=Config): | ||
app = Flask(__name__) | ||
app.config.from_object(Config) | ||
app.context_processor(inject_app_context) | ||
|
||
for _ext in _extensions: | ||
_ext.init_app(app) | ||
|
||
db.init_app(app) | ||
bcrypt.init_app(app) | ||
login_manager.init_app(app) | ||
admin_manager.init_app(app) | ||
# Add model views | ||
from FlaskRTBCTF.admin.views import MyModelView | ||
from FlaskRTBCTF.models import User, Score, Notification, Machine | ||
|
||
if LOGGING: | ||
from FlaskRTBCTF.models import Logs | ||
admin_manager.add_view(MyModelView(User, db.session)) | ||
admin_manager.add_view(MyModelView(Score, db.session)) | ||
admin_manager.add_view(MyModelView(Notification, db.session)) | ||
admin_manager.add_view(MyModelView(Machine, db.session)) | ||
if LOGGING: | ||
admin_manager.add_view(MyModelView(Logs, db.session)) | ||
mail.init_app(app) | ||
|
||
from flask_sslify import SSLify | ||
for _bp in _blueprints: | ||
app.register_blueprint(_bp) | ||
|
||
# only trigger SSLify if the app is running on Heroku | ||
if "DYNO" in os.environ: | ||
_ = SSLify(app) | ||
from flask_sslify import SSLify | ||
|
||
from FlaskRTBCTF.users.routes import users | ||
from FlaskRTBCTF.ctf.routes import ctf | ||
from FlaskRTBCTF.main.routes import main | ||
|
||
app.register_blueprint(users) | ||
app.register_blueprint(ctf) | ||
app.register_blueprint(main) | ||
_ = SSLify(app) | ||
|
||
return app |
Oops, something went wrong.