Skip to content
Merged
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
24 changes: 23 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,27 @@ jobs:
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.PROJECT_NAME }}_backend:latest


build_gateway_and_push_to_docker_hub:
name: Push gateway 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: ./gateway/
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.PROJECT_NAME }}_gateway:latest

deploy:
runs-on: ubuntu-latest
needs:
Expand Down Expand Up @@ -91,7 +112,8 @@ jobs:
sudo docker compose -f docker-compose.production.yml down
sudo docker compose -f docker-compose.production.yml up -d
sudo docker system prune -af



send_message:
runs-on: ubuntu-latest
needs: deploy
Expand Down
26 changes: 14 additions & 12 deletions docker-compose.production.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

version: '3.8'

volumes:
Expand Down Expand Up @@ -26,19 +27,20 @@ services:
frontend:
image: documents23/document-template-engine_frontend:latest
env_file: .env
command: cp -r /app/build/. /static/
volumes:
- ./frontend/:/app/result_build/
- static:/static

nginx:
image: nginx:1.19.3
gateway:
image: documents23/document-template-engine_gateway:latest
env_file: .env
ports:
- "8000:80"
- 8088:80
volumes:
- ./proxy-server/nginx.conf:/etc/nginx/conf.d/default.conf
- ./frontend/build:/usr/share/nginx/html/
- ./docs/:/usr/share/nginx/html/api/docs/
- static:/var/html/static/
- media:/var/html/media/
depends_on:
- backend
restart: always
- static:/staticfiles/
- media:/app/media/





17 changes: 6 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,11 @@ services:
volumes:
- ./frontend/:/app/result_build/

nginx:
image: nginx:1.19.3
gateway:
build: ./nginx/
env_file: .env
ports:
- "8000:80"
- 8088:80
volumes:
- ./proxy-server/nginx.conf:/etc/nginx/conf.d/default.conf
- ./frontend/build:/usr/share/nginx/html/
- ./docs/:/usr/share/nginx/html/api/docs/
- static:/var/html/static/
- media:/var/html/media/
depends_on:
- backend
restart: always
- static:/staticfiles/
- media:/app/media/
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
52 changes: 52 additions & 0 deletions gateway/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
server {
listen 80;

location /media/ {
proxy_set_header Host $http_host;
root /var/html/;
}

location /static/admin/ {
proxy_set_header Host $http_host;
root /var/html/;
}

location /static/rest_framework/ {
proxy_set_header Host $http_host;
root /var/html/;
}

location /static/drf-yasg/ {
proxy_set_header Host $http_host;
root /var/html/;
}

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

location /api/ {
proxy_set_header Host $http_host;
proxy_pass http://backend:9000/api/;
}

location /swagger/ {
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_set_header Host $http_host;
proxy_pass http://backend:9000/swagger/;
}

location /redoc/ {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_pass http://backend:9000/redoc/;
}

location / {
root /usr/share/nginx/html;
index index.html index.htm;

}
}

57 changes: 57 additions & 0 deletions инструкция.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Запуск бека на локальной машине

## Устанавливаем Python
Для работы бека нужен Python 3.9, для этого можно скачать с офф сайта или же через Microsoft Store(рекомендуется)

## Создаем виртуальное окружение
Через Bash заходим в папку с Backend(Там где находиться requirements.txt и manage.py) и прописываем команду

### Cоздать и активировать виртуальное окружение:
#### Создание виртуального окружения
```
python3.9 -m venv venv
```

#### Активация виртаульного окружения
##### Если у вас Linux/macOS
```
source venv/bin/activate
```

##### Если у вас windows
```
source venv/scripts/activate

```

### Установить зависимости из файла requirements.txt:
Скачиваем и устанавливаем все зависимости
```
python -m pip install --upgrade pip
pip install -r requirements.txt
```

### Выполнить миграции:
```
cd backend
python manage.py makemigrations
python manage.py migrate
```

### Запустить проект:
```
cd backend
python manage.py runserver
```

### Создать суперпользователя:
```
cd backend
python manage.py createsuperuser
```

### Добавить темлейтов в базу:
```
cd backend
python manage.py init_templates
```