Created Woodpecker CI/CD deployment
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- Created Dockerfile for packing up API and Web projects as Docker image
This commit is contained in:
63
API/Readme.md
Normal file
63
API/Readme.md
Normal file
@ -0,0 +1,63 @@
|
||||
# YABA: Yet Another Bookmark App
|
||||
|
||||
## YABA.API - Developer Guide
|
||||
|
||||
### Running Migrations
|
||||
When running migrations, .NET seems to be ignoring dependency injection settings. In order to get around this, be sure to add the connection string to the command like. For example, when adding the migration:
|
||||
|
||||
```
|
||||
dotnet ef migrations add InitialMigration -p YABA.Data -s YABA.API --context YABABaseContext -- {CONNECTION_STRING_HERE}
|
||||
```
|
||||
|
||||
When removing last migration:
|
||||
```
|
||||
dotnet ef migrations remove InitialMigration -p YABA.Data -s YABA.API --context YABABaseContext -- {CONNECTION_STRING_HERE}
|
||||
```
|
||||
|
||||
When applying migrations:
|
||||
```
|
||||
dotnet ef database update -p YABA.Data -s YABA.API -c YABABaseContext -- { CONNECTION_STRING_HERE }
|
||||
```
|
||||
|
||||
As per the documentation [on MSDN](https://learn.microsoft.com/en-ca/ef/core/cli/dbcontext-creation?tabs=dotnet-core-cli#from-application-services):
|
||||
> The -- token directs dotnet ef to treat everything that follows as an argument and not try to parse them as options. Any extra arguments not used by dotnet ef are forwarded to the app.
|
||||
|
||||
### Managing secrets
|
||||
|
||||
Best practice dictates that sensitive values should never be committed to source control. To manage secrets locally, this project utilize the [secrets manager](https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-7.0&tabs=windows).
|
||||
|
||||
To initialize a secrets manager:
|
||||
```
|
||||
dotnet user-secrets init --project YABA.API
|
||||
```
|
||||
|
||||
To set (or override) the value of a secret using a provided key:
|
||||
```
|
||||
dotnet user-secrets set "Key" "Value" --project YABA.API
|
||||
```
|
||||
```
|
||||
dotnet user-secrets set "Object:Property" "Value" --project YABA.API
|
||||
```
|
||||
|
||||
To list all secets:
|
||||
```
|
||||
dotnet user-secrets list --project YABA.API
|
||||
```
|
||||
|
||||
### Docker
|
||||
|
||||
To build a dockerized version of the API project:
|
||||
|
||||
```
|
||||
docker build { API_PROJECT_ROOT_SOURCE } -f { API_PROJECT_DOCKERFILE_PATH } -t { imagename:tag }
|
||||
```
|
||||
|
||||
In order to run a container using the image built above, keep the following things in mind:
|
||||
- It might be necessary to map container port 80 to another
|
||||
- In the absence of a linked user secrets, secrets will have to be passed in to the container as environment variables, prefixed with `ASPNETCORE_`
|
||||
|
||||
```
|
||||
docker run -d -p { HOST_PC_PORT_HERE }:80 --env ASPNETCORE_Object__Property=Value --name { CONTAINER_NAME } {imagename:tag}
|
||||
```
|
||||
|
||||
Environment variables that are explicitly listed in `YABA.API\Dockerfile` will have to be properly set for proper operation of the application
|
||||
Reference in New Issue
Block a user