Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu272 committed Jan 19, 2021
2 parents 990d09e + 4abe237 commit 7177f28
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .db.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=postgres
14 changes: 14 additions & 0 deletions .env.prod.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
SECRET_KEY=yourkeyhere
DEBUG=True
ALLOWED_HOSTS=127.0.0.1, localhost
GOOGLE_CLIENT_ID=google_client
GOOGLE_CLIENT_SECRET=google_secret_key
GITHUB_CLIENT_ID=github_id
GITHUB_CLIENT_SECRET=github_secret
GITHUB_REDIRECT_URI=redirect_uri
DB_NAME=postgres
DB_USER=postgres
DB_PASSWORD=postgres
DB_HOST=db
EXECUTOR_URL=http://127.0.0.1:5000/
CELERY_BROKER_URL=redis://redis:6379
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ db.sqlite3-journal
*.pyc
.env
.frnt.env
.env.prod
.db.env
.env.prod.proxy-comp
env/
.vscode
testcases/
Expand Down
22 changes: 12 additions & 10 deletions docker-compose.yml → docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ services:

db:
image: postgres:12
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
env_file:
.db.env
volumes:
- postgres_data:/var/lib/postgresql/data/

redis:
image: redis

web:
backend:
build: .
deploy:
restart_policy:
Expand All @@ -25,11 +23,12 @@ services:
python manage.py makemigrations interface &&
python manage.py migrate --noinput &&
python manage.py migrate --noinput interface &&
python manage.py collectstatic --no-input &&
python manage.py loaddata language_models.json &&
gunicorn judge.wsgi:application --bind 0.0.0.0:8000 --workers 4"
python manage.py runserver 0.0.0.0:8000"
volumes:
- .:/backend
- app:/backend:rw
- static:/backend/static/
- media:/backend/media/
env_file:
- .env
ports:
Expand All @@ -46,7 +45,7 @@ services:
depends_on:
- redis
- db
- web
- backend

frontend:
build: ./website
Expand All @@ -57,4 +56,7 @@ services:
- "3000:3000"

volumes:
postgres_data:
postgres_data:
app:
static:
media:
62 changes: 62 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
version: '3.7'

services:

db:
image: postgres:12
env_file:
.db.env
volumes:
- postgres_data:/var/lib/postgresql/data/

redis:
image: redis

backend:
build: .
deploy:
restart_policy:
condition: on-failure
max_attempts: 3
command: >-
bash -c "python manage.py makemigrations &&
python manage.py makemigrations interface &&
python manage.py migrate --noinput &&
python manage.py migrate --noinput interface &&
python manage.py collectstatic --no-input &&
python manage.py loaddata /backend/language_models.json &&
gunicorn judge.wsgi:application --bind 0.0.0.0:8000 --workers 4"
volumes:
- app:/backend:rw
- static:/backend/static/
- media:/backend/media/
env_file:
- .env.prod
ports:
- "8000:8000"
depends_on:
- db
- redis

executor:
image: phantsure/oj:latest
depends_on:
- redis
- db
- backend

celery:
build: .
command: celery -A judge worker -l info
volumes:
- .:/backend
depends_on:
- redis
- db
- backend

volumes:
postgres_data:
app:
media:
static:
1 change: 0 additions & 1 deletion website/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pull official base image
FROM node:13.12.0

RUN mkdir /frontend
Expand Down
8 changes: 8 additions & 0 deletions website/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:13.12.0

RUN mkdir /frontend
WORKDIR /frontend

COPY . .
RUN npm install
RUN npm run dev

1 comment on commit 7177f28

@vercel
Copy link

@vercel vercel bot commented on 7177f28 Jan 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.