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

Develop #15

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
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
6 changes: 6 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
venv
.env
.git
.idea
.vscode
db.sqlite3
13 changes: 13 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.10

WORKDIR /app

COPY requirements.txt .

RUN pip install gunicorn==20.1.0

RUN pip install -r /app/requirements.txt --no-cache-dir

COPY . .

CMD ["gunicorn", "--bind", "0.0.0.0:8000", "backend.wsgi"]
14 changes: 11 additions & 3 deletions backend/backend/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from pathlib import Path

BASE_DIR = Path(__file__).resolve().parent.parent
Expand All @@ -7,7 +9,7 @@

DEBUG = True

ALLOWED_HOSTS = []
ALLOWED_HOSTS = ['backend', 'localhost', '127.0.0.1']


# Application definition
Expand Down Expand Up @@ -61,8 +63,12 @@

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.getenv('POSTGRES_DB', 'django'),
'USER': os.getenv('POSTGRES_USER', 'django'),
'PASSWORD': os.getenv('POSTGRES_PASSWORD', ''),
'HOST': os.getenv('DB_HOST', ''),
'PORT': os.getenv('DB_PORT', 5432)
}
}

Expand Down Expand Up @@ -105,6 +111,8 @@

STATIC_URL = '/static/'

STATIC_ROOT = BASE_DIR / 'collected_static'

# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

Expand Down
3 changes: 2 additions & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Django==3.2.3
djangorestframework==3.12.4
django-cors-headers==3.13.0
django-cors-headers==3.13.0
psycopg2-binary==2.9.3
30 changes: 30 additions & 0 deletions docker-compose.production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: '3'

volumes:
pg_data_production:
static_volume:

services:
db:
image: postgres:13.10
env_file: .env
volumes:
- pg_data_production:/var/lib/postgresql/data
backend:
image: pakodeveloper/taski_backend
env_file: .env
volumes:
- static_volume:/backend_static
frontend:
image: pakodeveloper/taski_frontend
env_file: .env
command: cp -r /app/build/. /frontend_static/
volumes:
- static_volume:/frontend_static
gateway:
image: pakodeveloper/taski_gateway
env_file: .env
volumes:
- static_volume:/staticfiles/
ports:
- 8000:80
32 changes: 32 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: '3'

volumes:
pg_data:
static:

services:
db:
image: postgres:13.10
env_file: .env
volumes:
- pg_data:/var/lib/postgresql/data
backend:
build: ./backend/
env_file: .env
depends_on:
- db
volumes:
- static:/backend_static
frontend:
env_file: .env
build: ./frontend/
command: cp -r /app/build/. /frontend_static/
volumes:
- static:/frontend_static
gateway:
build: ./gateway/
env_file: .env
volumes:
- static:/staticfiles
ports:
- 8000:80
2 changes: 2 additions & 0 deletions frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
build
14 changes: 14 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:18
WORKDIR /app

COPY package.json package.json
COPY package-lock.json package-lock.json

RUN npm install

COPY . .

RUN npm run build
RUN npm install --global http-server

CMD ["npx", "-y", "http-server", "-p", "8000", "/app/build"]
2 changes: 2 additions & 0 deletions gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM nginx:1.22.1
COPY nginx.conf /etc/nginx/templates/default.conf.template
16 changes: 16 additions & 0 deletions gateway/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
server {
listen 80;
location /api/ {
proxy_set_header Host $http_host;
proxy_pass http://backend:8000/api/;
}
location /admin/ {
proxy_set_header Host $http_host;
proxy_pass http://backend:8000/admin/;
}

location / {
alias /staticfiles/;
try_files $uri $uri/ /index.html;
}
}