Backend/README.md
Sergey Karmanov 67e5d51014
All checks were successful
Lint / Run linters (push) Successful in 37s
Build and deploy / Publish image (push) Successful in 1m53s
Build and deploy / Deploy image (push) Successful in 11s
Обновил подключение к бд
2024-06-21 13:10:38 +03:00

81 lines
2.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Backend
Технологии:
* ASP.NET
* Aspire
* PostgreSQL
* Docker + Compose
* Nginx
* Github CI/CD
# ApiService
## Docker
```bash
docker run -d -p 8080:8080 \
--name Backend \
--restart=always \
-e DATABASE='Host=192.168.111.0;Port=5432;Database=prod;Username=prod;Password=' \
-e TZ=Europe/Moscow \
git.zetcraft.ru/hackathonpreparing/backend:main
```
## Docker compose
```yaml
version: '3.3'
services:
backend:
ports:
- 8080:8080
container_name: Backend
restart: always
environment:
- DATABASE=Host=192.168.111.0;Port=5432;Database=prod;Username=prod;Password=
- TZ=Europe/Moscow
image: git.zetcraft.ru/hackathonpreparing/backend:main
```
Строка подключения в appsettings.json:
username:postgres
password:postgres
host:localhost
port:5432
database:prod
Если нет миграций в проекте то в папке HackathonPreparing.ApiService нужно писать:
```sh
dotnet ef migrations add UserContextMigration --context UserContext
dotnet ef database update --context UserContext
dotnet ef migrations add WeatherForecastContextMigration --context WeatherForecastContext
dotnet ef database update --context WeatherForecastContext
```
```ps
dotnet-ef.exe migrations add UserContextMigration --context UserContext
dotnet-ef.exe database update --context UserContext
dotnet-ef.exe migrations add WeatherForecastContextMigration --context WeatherForecastContext
dotnet-ef.exe database update --context WeatherForecastContext
```
И так для каждого DbContext в проекте
Если в папке HackathonPreparing.ApiService есть папка Migrations и там есть миграции то можно просто сделать запрос post: /api/db/migrate.
Все запросы к маршрутам /api/db/... доступны только в dev моде
/api/swagger - путь к свагеру
из свагера в dev моде можно запустить миграции в /api/db/migrate