Skip to content

Commit

Permalink
Merge branch 'develop' into feature/profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadya2502 committed Mar 17, 2024
2 parents 34e4bee + aecc353 commit e70b7b7
Show file tree
Hide file tree
Showing 56 changed files with 3,614 additions and 890 deletions.
21 changes: 0 additions & 21 deletions .env.example

This file was deleted.

21 changes: 12 additions & 9 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
- name: Login to Docker
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Push to DockerHub
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: ./
push: true
Expand All @@ -30,16 +30,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
- name: Login to Docker
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Push to DockerHub
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: ./infra/nginx/
push: true
Expand All @@ -52,7 +52,7 @@ jobs:
- build_and_push_to_docker_hub_nginx
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Create project directory and .env-file
uses: appleboy/ssh-action@master
with:
Expand All @@ -72,12 +72,15 @@ 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 }}
EMAIL_HOST=${{ secrets.EMAIL_HOST }}
EMAIL_HOST_USER=${{ secrets.EMAIL_HOST_USER }}
EMAIL_HOST_PASSWORD=${{ secrets.EMAIL_HOST_PASSWORD }}
NEXT_PUBLIC_CAPTCHA_SITE_KEY=${{ secrets.NEXT_PUBLIC_CAPTCHA_SITE_KEY }}
NEXT_SHARP_PATH=${{ secrets.NEXT_SHARP_PATH }}
_EOF_
- name: Copy docker-compose-prod.yaml via ssh
uses: appleboy/scp-action@master
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/qa_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ jobs:
DOCKERHUB_USERNAME_FRONT=${{ secrets.DOCKERHUB_USERNAME_FRONT }}
DOCKERHUB_USERNAME=${{ secrets.DOCKERHUB_USERNAME }}
ALLOWED_HOSTS=${{ secrets.ALLOWED_HOSTS }}
EMAIL_HOST=${{ secrets.EMAIL_HOST }}
EMAIL_HOST_USER=${{ secrets.EMAIL_HOST_USER }}
EMAIL_HOST_PASSWORD=${{ secrets.EMAIL_HOST_PASSWORD }}
NEXT_PUBLIC_CAPTCHA_SITE_KEY=${{ secrets.NEXT_PUBLIC_CAPTCHA_SITE_KEY }}
NEXT_SHARP_PATH=${{ secrets.NEXT_SHARP_PATH }}
_EOF_
- name: Copy docker-compose-prod.yaml via ssh
uses: appleboy/scp-action@master
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ repos:
rev: v4.5.0
hooks:
- id: no-commit-to-branch
args: [-b main, -b develop]
args: [-b, main, -b, develop]
- id: detect-private-key
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
Expand Down
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ RUN apt-get update && apt-get install -y vim

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

COPY . .

WORKDIR /backend/src/backend
COPY /src/backend/. .

CMD gunicorn --bind 0.0.0.0:8000 config.wsgi
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RESTfull API приложение, разработанное для поиск
реализовать что-то новое, для менеджеров проектов и для компаний которые хотят
создать тестовое МВП нового продукта.

![workflow](https://github.com/Pet-projects-CodePET/Backend/actions/workflows/main.yml/badge.svg)
[![Code cheсks](https://github.com/Pet-projects-CodePET/Backend/actions/workflows/code_check.yml/badge.svg)](https://github.com/Pet-projects-CodePET/Backend/actions/workflows/code_check.yml)

## Стек технологий:

Expand Down
24 changes: 24 additions & 0 deletions infra/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Настройки backend
# Общие
SECRET_KEY=
# True - режим разработки | False - для продакшена
DEBUG=True
#Хосты через запятую
ALLOWED_HOSTS=localhost,127.0.0.1,
# True - sqlite | False - PostgeSQL
USE_SQLITE=False
# local - локальные настройки, dev - разработка, prod - продакшн
DJANGO_SETTINGS_MODULE=config.settings.dev

# Для PostgeSQL
DB_ENGINE=django.db.backends.postgresql
POSTGRES_DB=
POSTGRES_USER=
POSTGRES_PASSWORD=
POSTGRES_HOST=
POSTGRES_PORT=

# Переменные для работы с docker.
DOCKERHUB_USERNAME_FRONT=
DOCKERHUB_USERNAME=
PROJECT_NAME=
1 change: 0 additions & 1 deletion infra/dir.info

This file was deleted.

20 changes: 7 additions & 13 deletions infra/docker-compose-dev.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
services:

db:
image: postgres:latest
image: postgres:16.2-alpine
restart: always
ports:
- "5432:5432"
env_file: .env
volumes:
- db_value:/var/lib/postgresql/data/
environment:
- POSTGRES_DB=db
- POSTGRES_USER=admin
- POSTGRES_PASSWORD=admin


backend:
image: ${DOCKERHUB_USERNAME}/${PROJECT_NAME}_backend:latest
build: ../.
env_file: .env
ports:
- "8000:8000"
volumes:
- static_volume:/backend_static
- static_volume:/backend_static/
- ./.env:/app
depends_on:
- db

nginx:
image: ${DOCKERHUB_USERNAME}/${PROJECT_NAME}_nginx:latest
build: ./nginx/.
ports:
- "80:80"
- "443:443"
volumes:
- static_volume:/static
- static_volume:/staticfiles/
- /etc/letsencrypt:/etc/letsencrypt
depends_on:
- backend
Expand Down
48 changes: 37 additions & 11 deletions infra/docker-compose-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,70 @@ volumes:
pg_data:
static_volume:
media_value:
certbot:
letsencrypt:

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

backend:
image: ${DOCKERHUB_USERNAME}/${PROJECT_NAME}_backend:latest
restart: unless-stopped
env_file: .env
ports:
- "8000:8000"
volumes:
- static_volume:/backend_static/
- media_value:/backend_media/
depends_on:
- db
db:
condition: service_healthy

frontend:
image: ${DOCKERHUB_USERNAME_FRONT}/${PROJECT_NAME}_frontend:latest
command: cp -r out/. /frontend_static/
env_file: .env
volumes:
- static_volume:/frontend_static
depends_on:
db:
condition: service_healthy

nginx:
image: ${DOCKERHUB_USERNAME}/${PROJECT_NAME}_nginx:latest
ports:
- "80:80"
- "443:443"
volumes:
- static_volume:/staticfiles/
- media_value:/var/html/media/
- /etc/letsencrypt:/etc/letsencrypt
- certbot:/certbot/
- letsencrypt:/letsencrypt/
restart: unless-stopped
depends_on:
- backend
- frontend

frontend:
image: ${DOCKERHUB_USERNAME_FRONT}/${PROJECT_NAME}_frontend:latest
env_file: .env
ports:
- "3000:3000"
certbot:
image: certbot/certbot
volumes:
- static_volume:/frontend_static
- certbot:/certbot/
- letsencrypt:/letsencrypt/
restart: unless-stopped
depends_on:
- backend
- frontend
2 changes: 1 addition & 1 deletion infra/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM nginx:latest
FROM nginx:1.25.4-alpine-slim
COPY nginx.conf /etc/nginx/templates/default.conf.template
81 changes: 77 additions & 4 deletions infra/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,19 +1,92 @@
server {
listen 80;
listen [::]:80;
server_name 89.23.117.80 devcodepet.tw1.ru 89.23.117.168 testcodepet.tw1.ru;
server_name 89.23.117.80 devcodepet.tw1.ru 89.23.117.168 testcodepet.tw1.ru localhost;
server_tokens off;

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 /.well-known/acme-challenge/ {
root /certbot/;
}

location / {
alias /staticfiles/;
index index.html;
try_files $uri $uri/ /index.html;
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.80 devcodepet.tw1.ru;

# ssl_certificate /etc/nginx/ssl/live/devcodepet.tw1.ru/fullchain.pem;
# ssl_certificate_key /etc/nginx/ssl/live/devcodepet.tw1.ru/privkey.pem;
# include /etc/letsencrypt/options-ssl-nginx.conf;
# ssl_dhparam /etc/letsencrypt/ssl-dhparams.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 /etc/nginx/ssl/live/testcodepet.tw1.ru/fullchain.pem;
# ssl_certificate_key /etc/nginx/ssl/live/testcodepet.tw1.ru/privkey.pem;
# include /etc/letsencrypt/options-ssl-nginx.conf;
# ssl_dhparam /etc/letsencrypt/ssl-dhparams.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 e70b7b7

Please sign in to comment.