From b4005b88b252d9409a8618e22ba878851204c637 Mon Sep 17 00:00:00 2001 From: mradigen <55953083+mradigen@users.noreply.github.com> Date: Sun, 15 Sep 2024 22:51:24 +0530 Subject: [PATCH 1/3] chore: Add docker-compose.yaml --- docker-compose.yaml | 45 ++++++++++++++++++--------------- src/pwncore/__init__.py | 7 +++-- src/pwncore/routes/admin.py | 6 ++--- src/pwncore/routes/ctf/start.py | 3 ++- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 18237f8..c40b41a 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,22 +1,25 @@ services: - web: - image: reg.lugvitc.net/pwncore:latest - ports: - - "11000:8000" - environment: - - DATABASE_URL=postgresql://postgres:lugvitcrocks@db:5432/postgres - - WORKERS=4 - volumes: - - /var/run/docker.sock:/var/run/docker.sock - depends_on: - - db - - db: - image: postgres:14 - environment: - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=lugvitcrocks - - POSTGRES_DB=pwncore - - PGDATA=/var/lib/postgresql/data/pgdata - volumes: - - /home/lugvitc/cod3/postgresDB:/var/lib/postgresql/data + web: + image: reg.lugvitc.net/pwncore:latest + ports: + - ${PORT}:8000 + environment: + - DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB} + - WORKERS=${WORKERS} + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - ${CONFIG_FILE}:/app/src/pwncore/config.py + depends_on: + - db + db: + image: postgres:14 + user: ${UID}:${GID} + environment: + - POSTGRES_USER=${POSTGRES_USER} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} + - POSTGRES_DB=${POSTGRES_DB} + - PGDATA=/var/lib/postgresql/data/pgdata + volumes: + - ${DATA_PATH}:/var/lib/postgresql/data + ports: + - 5432:5432 diff --git a/src/pwncore/__init__.py b/src/pwncore/__init__.py index f91a713..b78885f 100644 --- a/src/pwncore/__init__.py +++ b/src/pwncore/__init__.py @@ -52,13 +52,12 @@ async def app_lifespan(app: FastAPI): app.include_router(routes.router) origins = [ - "http://ctf.lugvitc.org", - "https://ctf.lugvitc.org", + "http://c0d.lugvitc.net", + "https://c0d.lugvitc.net", ] if config.development: - origins.append("http://localhost:5173") - origins.append("http://localhost:4173") + origins.append("*") app.add_middleware( CORSMiddleware, diff --git a/src/pwncore/routes/admin.py b/src/pwncore/routes/admin.py index 4d35f3c..597aa61 100644 --- a/src/pwncore/routes/admin.py +++ b/src/pwncore/routes/admin.py @@ -29,7 +29,7 @@ if config.development: logging.basicConfig(level=logging.INFO) -ADMIN_HASH = "$2b$12$K2LsLGS/Mahksh0V6xZYKOviNEHMv3Of5f1zhyF6CWJ8rJIcKnSqu" +ADMIN_HASH = "$2b$12$USIGDWgl8WSgSoGauDTKE.ZAKyInaJn84fsZ.ARA6FmntIZeNCTUq" NAMES = [ "Mimas", "Enceladus", @@ -143,8 +143,8 @@ async def init_db( description="How to master the art of solving CTFs? Git good nub.", author="Aadivishnu and Shoubhit", points=300, - image_name="test:latest", - image_config={"PortBindings": {"22/tcp": [{}], "5000/tcp": [{}]}}, + image_name="reg.lugvitc.net/key:latest", + image_config={"PortBindings": {"22/tcp": [{}]}}, ) await Team.create(name="CID Squad", secret_hash=bcrypt.hash("veryverysecret")) await Team.create( diff --git a/src/pwncore/routes/ctf/start.py b/src/pwncore/routes/ctf/start.py index 7a70dea..fa80848 100644 --- a/src/pwncore/routes/ctf/start.py +++ b/src/pwncore/routes/ctf/start.py @@ -38,7 +38,8 @@ async def start_docker_container(ctf_id: int, response: Response, jwt: RequireJw if team_container: a, b = team_container[0], team_container[1:] db_ports = await a.ports.all().values("port") # Get ports from DB - ports = [db_port["port"] for db_port in db_ports] # Create a list out of it + ports = [db_port["port"] + for db_port in db_ports] # Create a list out of it for db_container in b: try: From 370a657d4bc7e6fa4e4e727d15521f7972e8d851 Mon Sep 17 00:00:00 2001 From: mradigen <55953083+mradigen@users.noreply.github.com> Date: Sun, 15 Sep 2024 22:54:28 +0530 Subject: [PATCH 2/3] ad: Add admin page --- docker-compose.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docker-compose.yaml b/docker-compose.yaml index c40b41a..efcee51 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -23,3 +23,16 @@ services: - ${DATA_PATH}:/var/lib/postgresql/data ports: - 5432:5432 + admin: + image: mathesar/mathesar-prod:latest + ports: + - ${PORT_ADMIN}:8000 + environment: + - POSTGRES_DB=${POSTGRES_DB} + - POSTGRES_USER=${POSTGRES_USER} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} + - POSTGRES_HOST=db + - POSTGRES_PORT=5432 + - MATHESAR_DB_URI=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB} + depends_on: + - db From f8cc695f7fd93c322119e49724dd9f90b03cc218 Mon Sep 17 00:00:00 2001 From: mradigen <55953083+mradigen@users.noreply.github.com> Date: Sun, 15 Sep 2024 23:02:07 +0530 Subject: [PATCH 3/3] chore: Fix admin page config --- docker-compose.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index efcee51..b007d03 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -27,12 +27,5 @@ services: image: mathesar/mathesar-prod:latest ports: - ${PORT_ADMIN}:8000 - environment: - - POSTGRES_DB=${POSTGRES_DB} - - POSTGRES_USER=${POSTGRES_USER} - - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} - - POSTGRES_HOST=db - - POSTGRES_PORT=5432 - - MATHESAR_DB_URI=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB} depends_on: - db