Skip to content
Open
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
23 changes: 16 additions & 7 deletions .github/workflows/Django-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [feature/backend-setup]
pull_request:
branches: [main]
branches: [main, feature/backend-setup]

jobs:
build:
Expand Down Expand Up @@ -42,13 +42,22 @@ jobs:
- name: Run Django tests with coverage
env:
DJANGO_SETTINGS_MODULE: backend.settings
POSTGRES_USER: postgres
POSTGRES_PASSWORD: asd123
POSTGRES_DB: workwise_db
DATABASE_HOST: localhost
DATABASE_PORT: 5432
DB_USER: postgres
DB_PASSWORD: asd123
DB_DB: workwise_db
DB_HOST: localhost
DB_PORT: 5432
run: |
cd backend
coverage run manage.py test
coverage report



- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin

- name: Build Docker image
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/workwise-backend:latest -f Dockerfile .

- name: Push Docker image to Docker Hub
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/workwise-backend:latest
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3.10-slim

WORKDIR /app

COPY backend/ /app/

RUN pip install -r requirements.txt

CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
14 changes: 0 additions & 14 deletions backend/Dockerfile

This file was deleted.

12 changes: 6 additions & 6 deletions backend/backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []
ALLOWED_HOSTS = ['*']


# Application definition
Expand Down Expand Up @@ -108,11 +108,11 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'workwise_db', # Your PostgreSQL database name
'USER': 'postgres', # Your PostgreSQL username
'PASSWORD': 'asd123', # Your PostgreSQL password
'HOST': 'localhost', # The database host
'PORT': '5432', # The PostgreSQL port
'NAME': os.environ.get('DB_NAME', 'workwise_db'),
'USER': os.environ.get('DB_USER', 'postgres'),
'PASSWORD': os.environ.get('DB_PASSWORD', 'asd123'),
'HOST': os.environ['DB_HOST'],
'PORT': os.environ.get('DB_PORT', '5432'),
}
}

Expand Down
2 changes: 1 addition & 1 deletion backend/backend/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<h1>Welcome to the Workwise Homepage!</h1>
<h2>Group 7</h2>
<ul>
<li>Akash Dewayalage (8935920)</li>
<li>Akash Tharindu (8935920)</li>
<li>Gunsu Lee (8926937)</li>

<li>Priya Singh (8920481)</li>
Expand Down
2 changes: 1 addition & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ django-cors-headers==4.6.0
django-extensions==3.2.3
djangorestframework==3.15.2
djangorestframework-simplejwt==5.3.1
psycopg2==2.9.9
psycopg2-binary>=2.9
PyJWT==2.9.0
sqlparse==0.5.1
tzdata==2024.2
26 changes: 26 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: "3.8"

services:
db:
image: postgres:15
environment:
POSTGRES_DB: workwise_db
POSTGRES_USER: postgres
POSTGRES_PASSWORD: asd123
ports:
- "5432:5432"

backend:
build: .
volumes:
- ./backend:/app
ports:
- "8000:8000"
depends_on:
- db
environment:
- DB_NAME=workwise_db
- DB_USER=postgres
- DB_PASSWORD=asd123
- DB_HOST=db
- DB_PORT=5432