Skip to content

Commit

Permalink
Merge pull request #147 from Pet-projects-CodePET/develop
Browse files Browse the repository at this point in the history
merge from develop
  • Loading branch information
VladislavCR authored Mar 26, 2024
2 parents 41f8a2d + 82873ee commit 3538ea5
Show file tree
Hide file tree
Showing 44 changed files with 1,327 additions and 65 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
with:
context: ./infra/nginx/
push: true
build-args: NGINX_NAME=${{ secrets.NGINX_DEV }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PROJECT_NAME }}_nginx:latest

build_and_push_to_docker_hub_certbot:
Expand All @@ -63,6 +64,7 @@ jobs:
with:
context: ./infra/certbot/
push: true
build-args: DOMAIN_NAME=${{ secrets.DOMAIN_DEV }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PROJECT_NAME }}_certbot:latest

deploy:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/qa_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ jobs:
POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}
PROJECT_NAME=${{ secrets.PROJECT_NAME }}
SECRET_KEY=${{ secrets.SECRET_KEY }}
DJANGO_SETTINGS_MODULE=${{ secrets.DJANGO_SETTINGS_MODULE }}
DOCKERHUB_USERNAME_FRONT=${{ secrets.DOCKERHUB_USERNAME_FRONT }}
DOCKERHUB_USERNAME=${{ secrets.DOCKERHUB_USERNAME }}
ALLOWED_HOSTS=${{ secrets.ALLOWED_HOSTS }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ cover/
local_settings.py
db.sqlite3
db.sqlite3-journal
*.sqlite3

# Flask stuff:
instance/
Expand Down
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ repos:
hooks:
- id: isort

- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
args: [--config=flake8, src/backend/]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
Expand Down
7 changes: 7 additions & 0 deletions flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[flake8]
extend-ignore = E203
exclude =
__pycache__,
**/migrations/*,
src/backend/config/settings/*
max-complexity = 10
4 changes: 2 additions & 2 deletions infra/certbot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ FROM certbot/certbot

ARG DOMAIN_NAME

COPY fullchain.pem etc/letsencrypt/live/testcodepet.tw1.ru/fullchain.pem
COPY fullchain.pem letsencrypt/live/${DOMAIN_NAME}/fullchain.pem

COPY privkey.pem etc/letsencrypt/live/testcodepet.tw1.ru/privkey.pem
COPY privkey.pem letsencrypt/live/${DOMAIN_NAME}/privkey.pem
1 change: 1 addition & 0 deletions infra/docker-compose-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ services:

nginx:
build: ./nginx/.
env_file: .env
ports:
- "80:80"
- "443:443"
Expand Down
78 changes: 78 additions & 0 deletions infra/docker-compose-local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: code-pet

services:
db:
image: postgres:16.2-alpine
restart: always
env_file: .env
ports:
- "5432:5432"
volumes:
- db_value:/var/lib/postgresql/data/
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
interval: 3s
timeout: 3s
retries: 5

backend:
build: ../.
env_file: .env
volumes:
- static_volume:/backend_static/
- ./.env:/app
command:
- /bin/sh
- -c
- |
python manage.py collectstatic -c --noinput
cp -r /backend/static/. /backend_static/static
python manage.py makemigrations
python manage.py migrate
gunicorn --bind 0.0.0.0:8000 config.wsgi
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy

redis:
image: redis:alpine3.18
restart: unless-stopped
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5

celery:
build: ../.
env_file: .env
command: celery -A config.celery worker -l info -E
volumes:
- ./.env:/app
depends_on:
- backend

celery-beat:
build: ../.
env_file: .env
command: celery -A config beat -l info
volumes:
- ./.env:/app
depends_on:
- backend

nginx:
image: nginx:1.25.2-alpine3.18-slim
ports:
- "80:80"
volumes:
- ./nginx/nginx_loc.conf:/etc/nginx/conf.d/default.conf
- static_volume:/staticfiles/
depends_on:
- backend

volumes:
db_value:
static_volume:
2 changes: 1 addition & 1 deletion infra/nginx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ FROM nginx:1.25.4-alpine-slim

ARG NGINX_NAME

COPY nginx_qa.conf /etc/nginx/templates/default.conf.template
COPY ${NGINX_NAME} /etc/nginx/templates/default.conf.template
24 changes: 21 additions & 3 deletions infra/nginx/nginx_dev.conf
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
server {
listen 80;
listen [::]:80;
server_name 89.23.117.80 devcodepet.tw1.ru;
server_name 89.23.117.80;
server_tokens off;

root /staticfiles;

location / {
return 301 https://devcodepet.tw1.ru$request_uri;
}
}

server {
listen 80;
listen [::]:80;
server_name devcodepet.tw1.ru;
server_tokens off;

root /staticfiles;

location /.well-known/acme-challenge/ {
root /certbot;
root /certbot;
}

location /admin/ {
proxy_set_header Host $http_host;
proxy_pass http://backend:8000/admin/;
}

location / {
Expand Down Expand Up @@ -35,7 +53,7 @@ server {
}

location /.well-known/acme-challenge/ {
root /certbot;
root /certbot;
}

location / {
Expand Down
61 changes: 33 additions & 28 deletions infra/nginx/nginx_qa.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,41 @@ server {
root /certbot;
}

location /admin/ {
proxy_set_header Host $http_host;
proxy_pass http://backend:8000/admin/;
}

location / {
return 301 https://$host$request_uri;
}
}

# server {
# listen 443 default_server ssl http2;
# listen [::]:443 ssl http2;
# server_name 89.23.117.168 testcodepet.tw1.ru;

# ssl_certificate /letsencrypt/live/testcodepet.tw1.ru/fullchain.pem;
# ssl_certificate_key /letsencrypt/live/testcodepet.tw1.ru/privkey.pem;

# root /staticfiles;

# location /api/v1/ {
# proxy_set_header Host $http_host;
# proxy_pass http://backend:8000/api/v1/;
# }
# location /admin/ {
# proxy_set_header Host $http_host;
# proxy_pass http://backend:8000/admin/;
# }

# location / {
# try_files $uri $uri.html $uri/ =404;
# }

# error_page 404 /404.html;
# location = /404.html {
# internal;
# }
# }
server {
listen 443 default_server ssl http2;
listen [::]:443 ssl http2;
server_name 89.23.117.168 testcodepet.tw1.ru;

ssl_certificate /letsencrypt/live/testcodepet.tw1.ru/fullchain.pem;
ssl_certificate_key /letsencrypt/live/testcodepet.tw1.ru/privkey.pem;

root /staticfiles;

location /api/v1/ {
proxy_set_header Host $http_host;
proxy_pass http://backend:8000/api/v1/;
}
location /admin/ {
proxy_set_header Host $http_host;
proxy_pass http://backend:8000/admin/;
}

location / {
try_files $uri $uri.html $uri/ =404;
}

error_page 404 /404.html;
location = /404.html {
internal;
}
}
Loading

0 comments on commit 3538ea5

Please sign in to comment.