Skip to content

Commit

Permalink
Add nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpro2022 committed Mar 19, 2024
1 parent 2ba2c4f commit 605fb22
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
source: "docker/server.docker-compose.yml"
source: "docker/server.docker-compose.yml, docker/nginx.conf"
target: ${{ secrets.PROJECT_NAME }}
overwrite: true
strip_components: 1
Expand Down
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# hrspace-request-builder-backend
[![CI/CD](https://github.com/hrspace-request-builder/hrspace-request-builder-backend/actions/workflows/main.yml/badge.svg)](https://github.com/hrspace-request-builder/hrspace-request-builder-backend/actions/workflows/main.yml)

Проект развернут на удаленном сервере:
- Swagger доступен по адресу http://185.221.162.231:8000/docs
- админ панель доступна по адресу http://185.221.162.231:8000/admin
Проект развернут на удаленном сервере по адресу http://185.221.162.231/hrspace:
- админ панель доступна по адресу http://185.221.162.231/admin
- Swagger доступен по адресу http://185.221.162.231/docs
- Redoc доступен по адресу http://185.221.162.231/redoc

<br>

## Установка приложения:

Expand Down Expand Up @@ -35,11 +38,15 @@ nano .env
```bash
docker compose -f docker/docker-compose.yml --env-file .env up -d --build
```
Проект будет развернут в docker-контейнерах по адресу http://127.0.0.1:8000.
Проект будет развернут в docker-контейнерах по адресу http://localhost/hrspace

Администрирование приложения может быть осуществлено:
- через Swagger доступный по адресу http://127.0.0.1:8000/docs
- через админ панель по адресу http://127.0.0.1:8000/admin
- через Swagger доступный по адресу http://localhost/docs
- через админ панель по адресу http://localhost/admin

Техническая документация:
- Swagger доступен по адресу http://localhost/docs
- Redoc доступен по адресу http://localhost/redoc

<br>
2. Остановить docker и удалить контейнеры можно командой из корневой директории проекта:
Expand Down
24 changes: 20 additions & 4 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ services:
- db_data:/var/lib/postgresql/data/
environment:
- POSTGRES_PASSWORD=$POSTGRES_PASSWORD
ports:
- $DB_PORT:$DB_PORT
expose:
- $DB_PORT
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $POSTGRES_USER -d $POSTGRES_DB"]
interval: 10s
Expand All @@ -28,10 +28,26 @@ services:
depends_on:
db:
condition: service_healthy
ports:
- 8000:8000
expose:
- 8000
env_file:
- ../.env

frontend:
image: alexpro1972/hrspace_frontend
expose:
- 3000

nginx:
image: nginx:1.21.3-alpine
restart: always
depends_on:
- frontend
- backend
ports:
- "80:80"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf

volumes:
db_data:
19 changes: 19 additions & 0 deletions docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
server {
listen 80;
server_name "$hostname";
server_tokens off;

location /hrspace {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_pass http://frontend:3000;
}

location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_pass http://backend:8000;
}
}
21 changes: 16 additions & 5 deletions docker/server.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ services:
- db_data:/var/lib/postgresql/data/
environment:
- POSTGRES_PASSWORD=$POSTGRES_PASSWORD
ports:
- $DB_PORT:$DB_PORT
expose:
- $DB_PORT

backend:
image: "${DOCKERHUB_USERNAME}/${PROJECT_NAME}_backend"
Expand All @@ -18,15 +18,26 @@ services:
restart: always
depends_on:
- db
ports:
- 8000:8000
expose:
- 8000
env_file:
- ./.env

frontend:
image: "${DOCKERHUB_USERNAME}/${PROJECT_NAME}_frontend"
expose:
- 3000

nginx:
image: nginx:1.21.3-alpine
restart: always
depends_on:
- frontend
- backend
ports:
- 3000:3000
- "80:80"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf

volumes:
db_data:

0 comments on commit 605fb22

Please sign in to comment.