Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docker-compose.yaml and production changes #50

Merged
merged 3 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 30 additions & 21 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
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
admin:
image: mathesar/mathesar-prod:latest
ports:
- ${PORT_ADMIN}:8000
depends_on:
- db
7 changes: 3 additions & 4 deletions src/pwncore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/pwncore/routes/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion src/pwncore/routes/ctf/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading