-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
615 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
SECRET_KEY=some-secret-key | ||
SEND_EMAIL=False | ||
|
||
EMAIL_HOST= | ||
EMAIL_PORT= | ||
EMAIL_USE_SSL= | ||
DEFAULT_FROM_EMAIL= | ||
EMAIL_HOST_USER= | ||
EMAIL_HOST_PASSWORD= | ||
EMAIL_BACKEND= | ||
|
||
POSTGRES_ENGINE=django.db.backends.postgresql | ||
POSTGRES_USER= | ||
POSTGRES_PASSWORD= | ||
POSTGRES_DB= | ||
POSTGRES_HOST= | ||
POSTGRES_PORT=5432 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Main todo-tracker workflow | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build_and_push_to_docker_hub: | ||
name: Push Docker image to DockerHub | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Login to Docker | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Push to DockerHub | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: ./todo_tracker/ | ||
push: true | ||
tags: ${{ secrets.DOCKER_USERNAME }}/todo_tracker:latest | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build_and_push_to_docker_hub | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
- name: Copy docker-compose.yml via ssh | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USER }} | ||
key: ${{ secrets.SSH_KEY }} | ||
passphrase: ${{ secrets.SSH_PASSPHRASE }} | ||
source: "docker-compose.yml" | ||
target: "todo_tracker" | ||
- name: Executing remote ssh commands to deploy | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USER }} | ||
key: ${{ secrets.SSH_KEY }} | ||
passphrase: ${{ secrets.SSH_PASSPHRASE }} | ||
script: | | ||
cd todo_tracker | ||
git pull origin | ||
sudo docker compose -f docker-compose.yml pull | ||
sudo docker compose -f docker-compose.yml down | ||
sudo docker compose -f docker-compose.yml up -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"isort.importStrategy": "useBundled", | ||
"markdown-pdf.convertOnSave": true, | ||
"markdown-pdf.convertOnSaveExclude": [ | ||
"^work", | ||
"work.md$", | ||
"^(?![Rr][Ee][Aa][Dd][Mm][Ee]).*$", | ||
"work|test", | ||
"[0-9][0-9][0-9][0-9]-work", | ||
"work\\test" // All '\' need to be written as '\\' (Windows) | ||
], | ||
"markdown-pdf.type": [ | ||
"pdf" | ||
], | ||
"python.analysis.autoImportCompletions": true, | ||
"python.analysis.completeFunctionParens": false, | ||
"python.formatting.provider": "none", | ||
"python.formatting.blackArgs": [ | ||
"--line-length", | ||
"79" | ||
], | ||
"python.linting.enabled": true, | ||
"python.linting.flake8Enabled": true, | ||
"[python]": { | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": true | ||
}, | ||
"editor.defaultFormatter": "ms-python.black-formatter", | ||
"editor.formatOnSave": true, | ||
"editor.formatOnType": true, | ||
"editor.insertSpaces": true, | ||
"editor.tabSize": 4 | ||
}, | ||
"python.analysis.typeCheckingMode": "off" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
version: '3.3' | ||
|
||
volumes: | ||
pg_data: | ||
static_todo_tracker: | ||
media_todo_tracker: | ||
|
||
|
||
services: | ||
db: | ||
image: postgres:13 | ||
volumes: | ||
- pg_data:/var/lib/postgresql/data | ||
env_file: | ||
- .env | ||
|
||
todo_tracker: | ||
image: agas0077/todo_tracker:latest | ||
env_file: .env | ||
depends_on: | ||
- db | ||
restart: on-failure:2 | ||
volumes: | ||
- static_todo_tracker:/app/staticfiles/ | ||
- media_todo_tracker:/app/media/ | ||
command: > | ||
bash -c "python manage.py migrate | ||
&& python manage.py collectstatic --no-input | ||
&& gunicorn --bind 0.0.0.0:8000 todo_tracker.wsgi" | ||
nginx: | ||
depends_on: | ||
- todo_tracker | ||
image: nginx:1.19.3 | ||
ports: | ||
- "8004:80" | ||
volumes: | ||
- ./nginx/todo_tracker.conf:/etc/nginx/conf.d/default.conf | ||
- ./nginx/nginx.conf:/etc/nginx/nginx.conf | ||
- static_todo_tracker:/static | ||
- media_todo_tracker:/media |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FROM nginx:1.22.1 | ||
COPY nginx.conf /etc/nginx/conf.d/default.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
user nginx; | ||
worker_processes 1; | ||
|
||
error_log /var/log/nginx/error.log warn; | ||
pid /var/run/nginx.pid; | ||
|
||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
|
||
http { | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
client_max_body_size 100m; | ||
|
||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
access_log /var/log/nginx/access.log main; | ||
|
||
sendfile on; | ||
#tcp_nopush on; | ||
|
||
keepalive_timeout 65; | ||
|
||
#gzip on; | ||
|
||
include /etc/nginx/conf.d/*.conf; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
server { | ||
listen 80; | ||
|
||
location / { | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_pass_header X-XSRF-TOKEN; | ||
proxy_set_header Host $http_host; | ||
proxy_pass http://todo_tracker:8000/; | ||
} | ||
|
||
location /static/ { | ||
alias /static/; | ||
} | ||
|
||
location /media/ { | ||
alias /media/; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[tool.black] | ||
line-length = 79 | ||
include = 'todo_tracker/.*.py' | ||
extend-exclude = ''' | ||
( | ||
migrations/* | | ||
static/* | ||
) | ||
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
[flake8] | ||
accept-encodings = utf-8 | ||
statistics = False | ||
max-line-length = 79 | ||
doctests = False | ||
enable-extensions = G | ||
isort-show-traceback = True | ||
|
||
exclude = | ||
.git, | ||
.venv, | ||
.vscode/*.py, | ||
pycache, | ||
/site-packages//*.py, | ||
migrations | ||
|
||
extend-ignore = E203 | ||
|
||
ignore = | ||
C901, | ||
F40, | ||
E211, | ||
E225, | ||
E226, | ||
E231, | ||
E303, | ||
E711, | ||
E712, | ||
|
||
[isort] | ||
profile = black | ||
import_heading_stdlib=Standard Library | ||
import_heading_thirdparty=Third Party Library | ||
import_heading_localfolder=Local Modules | ||
known_local_folder = src | ||
line_length = 79 | ||
multi_line_output = 3 | ||
include_trailing_comma = True | ||
force_grid_wrap = 0 | ||
use_parentheses = True | ||
ensure_newline_before_comments = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.venv | ||
.git | ||
__pycache__ | ||
db.sqlite3 | ||
.env | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM python:3.9 | ||
|
||
WORKDIR /app | ||
|
||
RUN pip install gunicorn==20.1.0 | ||
|
||
COPY ./requirements.txt . | ||
|
||
RUN pip install -r /app/requirements.txt --no-cache-dir | ||
|
||
COPY . . | ||
|
||
CMD [ "gunicorn", "--bind", "0.0.0.0:8000", "todo_tracker.wsgi" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# Third Party Library | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# Third Party Library | ||
from django.apps import AppConfig | ||
|
||
|
||
class ApiConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'api' | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# Third Party Library | ||
from django.db import models | ||
|
||
# Create your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# Third Party Library | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
Oops, something went wrong.