REST API for the completion module in Project Completion System (ProCoSys (PCS))
Before running the application, some settings need to be set. These are defined in appsettings.json. To avoid the possibility to commit secrets, move parts of the configuration to the secrets.json file on your computer. Typical settings that should be moved to secrets.json are:
- AD IDs
- Keys
- Local URLs
- Other secrets
When running in development environment, the database is auto-migrated on application startup. This can be changed using the setting in appsettings.development.json.
The database can be seeded with test data. To do this, enable the feature in appsettings.development.json and start the application.
Note: This will run every time the application starts. To avoid multiple seedings, disable the feature after the application has started.
To open secrets.json, right-click on the startup project and select 'Manage User Secrets'.
Choose to run as Equinor.ProCoSys.Completion.WebApi in the dropdown menu and hit F5.
This guide will help you set up your local environment to run the application using Docker Compose.
- Docker and Docker Compose installed.
- Access to ProCoSys Official NuGet feed.
- Access to Azure Container Registry.
Before running the application, you need to set up the following:
Ensure you have a populated secret.json
created from Equinor.ProCoSys.Completion.WebApi.
Either with full setup, or minimal.
Ask a colleague for a copy if you dont have one.
Create a .env
file in the src directory (next to docker-compose) with the following content:
FEED_TOKEN= YourAccessTokenHere
.env is and should be ignored by git.
Note: Make sure to double check that this file is not added to source control.
The .env file should never be checked in to source control. As long as its placed in the src folder, it will be ignored by git. But always double check before committing.
Replace ACCESSTOKEN
with your actual access key to the ProCoSys Official NuGet feed.
We use Personal AccessTokens and the token needs the permission Packaging (read)
.
This means that you give the container permission to access the feed on your behalf.
If you dont already have one, it can be created here: https://statoildeveloper.visualstudio.com/_usersSettings/tokens
Follow the guide provided here to log in to the Azure Container Registry from your command window.
Modify the server
part of the database connection string to use db
instead of 127.0.0.1
.
You find the connection string in the secret.json
. Change the value of "ConnectionStrings:CompletionContext":
from Server=127.0.0.1;Database=pcs-co...
to Server=db;Database=pcs-co...
run the following command to add a self trusted certificate for the project in a folder where docker can reach it (the folder we mount)
dotnet dev-certs https -ep $env:APPDATA\ASP.NET\Https\Equinor.ProCoSys.Completion.WebApi.pfx -p <superSecretPassword>
and then
dotnet dev-certs https --trust
add this line to secret.json
using the same password
"Kestrel:Certificates:Development:Password": "<superSecretPassword>",
Once all configuration is done, you can start the application by running the following command from the src folder:
cd src
and then
docker compose up
This will pull the necessary images, build the services, and start the application. You can access it once it's up and running.
To debug in the container, you can run the application from visual studio or rider.
There is a sandbox image available at procosys.azurecr.io/completion/sandbox:latest. IDs in this image matches IDs in the main sandbox image. This sandbox image is based on this backup pcsdevsa/sql-db-backup-sandbox/pcs-completion-dev-db
The One Team Documentation has higher level documentation for the program. Please familiarize yourself with it.
Deleting all local branches except for main
git for-each-ref --format '%(refname:short)' refs/heads | grep -v "main" | xargs git branch -D
If you want to contribute to this project, please see: CONTRIBUTING.md.