-
Notifications
You must be signed in to change notification settings - Fork 1
VI. Deployment
This page will give a brief overview of the deployment of the application and how to use it. It will cover the automatic deployment with Github Actions or the manual local deployment.
As part of the CI/CD pipeline, the projects shared libraries are published as NuGet packages. The packages are published to the GitHub Package Registry.
To use the packages, there are two ways. Use the packages that are published to the GitHub Package Registry or build and pack the NuGet packages locally.
To use the packages from the GitHub Package Registry, add the GitHub Package Registry as a package source. To do this, add the following configuration to your NuGet configuration file. The configuration file is located at %appdata%\NuGet\NuGet.Config on Windows and ~/.nuget/NuGet/NuGet.Config on Linux.
Run dotnet nuget add source https://nuget.pkg.github.com/fredyyy998/index.json -n github -u <username> -p <access_key> to add the source to the NuGet.Config or
Add the following code:
<configuration>
... other configuration
<packageSources>
... other sources
<add key="github" value="https://nuget.pkg.github.com/fredyyy998/index.json" />
</packageSources>
<packageSourceCredentials>
<github>
<add key="Username" value="<username>" />
<add key="ClearTextPassword" value="<access_key>" />
</github>
</packageSourceCredentials>
</configuration>
As username insert your github username. For the access_key generate a personal access token with rights to atleast read packages(read:packages). Access tokens can be generated at Settings > Developer Settings > Personal Access Tokens > Tokens classic. Read more about permissions for packages
After this setup the packages should be available in the project. Otherwise reload the NuGet packages in the NuGet package manager.
To use the packages locally, build and pack the packages locally. To do that the steps below can be followed:
- Go into the Common solution
src/Ecommerce.Common - Build the package by yourself and pack the project with
dotnet pack -o <direcotry path>to some output directory - Reference the local package directory in your NuGet.Config, run
dotnet nuget add source <direcotry path>to add the source to the NuGet.Config or
Add the following code:
<configuration>
... other configuration
<packageSources>
... other sources
<add key="Offline Packages" value="<direcotry path>" />
</packageSources>
</configuration>
After any of these setups, the packages should be available in the project. Otherwise reload the NuGet packages in the NuGet package manager.
To update the packages, you need to update the version in the Ecommerce.Common.csproj file. To publish the packages trigger the CI/CD pipeline NuGet Package. The pipeline will build and publish the packages to the GitHub Package Registry and the new versions of the packages will be available.
The projects services are build as Docker images and published to the GitHub Container Registry. The images are build with the GitHub Actions, these must be triggered manually.
The packages can either be pulled from the GitHub container registry or build locally.
A single image can be used by pulling the image from the GitHub Container Registry. To do this simply run docker pull ghcr.io/fredyyy998/<service name>:<tag>. For tag is is recommended to use latest, since there is no versioning yet.
However it is simpler to start the whole application with the docker-compose file. To do this run docker-compose up. This will start the whole application with the latest images.
There is also the possiblity to not use the docker images from the github repository. To use localy build images follow these steps:
- Have the Nuget Packages ready to use
- Have the database migrated like explained in the Getting Started section step 4
- Build every service with the command
dotnet publish <service_name>.Web -c Releasewithin the root of the service - After every service is build use
docker-compose -f docker-compose.local.yml up
To update the images, you can simply trigger the CI/CD pipeline Docker Images. The pipeline will build and publish the images to the GitHub Container Registry and the new versions of the images will be available. To use the newly published images, you need to pull the images again. You could also delete the old images for each service, and when the container start again they will pull automatically. However, there must be some manual work involved.