This guide outlines the steps to deploy the stevedunn/vogen
project into a production environment. It assumes familiarity with C#, PowerShell, and Docker.
Prerequisites
- Ensure that Docker is installed on your deployment environment.
- Verify that .NET SDK version 7.0 is available.
- The deployment includes building the project artifacts and running tests; thus, make sure you have the necessary permissions to execute PowerShell scripts and Docker containers.
Step 1: Prepare the Docker Environment
The Dockerfile
is set up to create an image for the vogen
application. The first step is to build this Docker image.
Dockerfile Overview
FROM mcr.microsoft.com/dotnet/sdk:7.0
COPY . .
ENTRYPOINT [ "powershell.exe", "./Build.ps1" ]
This Dockerfile
does the following:
- Uses the .NET SDK 7.0 as the base image.
- Copies the entire project directory into the container.
- Sets the entry point to execute the
Build.ps1
PowerShell script.
Building the Docker Image
Run the following command to build your Docker image:
docker build -t vogen:latest .
Step 2: Build and Test the Application
The Build.ps1
script orchestrates building the application and running tests. The script is invoked as the entry point in the Docker container.
Build Script Overview
Here are critical sections of the Build.ps1
script for the production deployment process:
WriteStage("Cleaning, restoring, and building release version of Vogen...")
WriteStage("... clean ...")
exec { & dotnet clean Vogen.sln -c Release --verbosity $verbosity}
WriteStage("... restore ...")
exec { & dotnet restore Vogen.sln --no-cache --verbosity $verbosity }
exec { & dotnet build Vogen.sln -c Release -p Thorough=true --no-restore --verbosity $verbosity }
- The script first cleans any previous builds, restores the dependencies, and then builds the solution in release mode.
Running Tests
The script also contains steps to run tests:
WriteStage("Running consumer tests in debug with the local version of the NuGet package:" +$version)
exec { & dotnet test ./tests/ConsumerTests -c Debug --no-build --no-restore --verbosity $verbosity }
The command above runs the consumer tests. Add a step to also run release tests:
WriteStage("Re-running tests in release with the local version of the NuGet package:" + $version)
exec { & dotnet test ./tests/ConsumerTests -c Release --no-build --no-restore --verbosity $verbosity }
Complete Build and Test
Ensure to include all build and test phases in your PowerShell script to validate your application correctly before deployment.
Step 3: Package the Application
Once the application is built and tested successfully, package the release artifacts:
WriteStage("Finally, packing the release version into " + $artifacts)
exec { & dotnet pack src/Vogen.Pack.csproj -c Release -o $artifacts --no-build --verbosity $verbosity }
This command packages the application into the specified artifacts directory.
Step 4: Running the Application in Production
After packaging, run the application using the appropriate orchestration method (Kubernetes, Docker Compose, etc.). Ensure that the application is configured to listen on the correct ports and is accessible as needed.
Example command to run the Docker container:
docker run -d --name vogen_app -p 8080:80 vogen:latest
This command runs the application in detached mode, mapping port 8080 on the host to port 80 in the container.
Conclusion
This guide provides an in-depth process for deploying the stevedunn/vogen
project into a production environment. By following these steps, developers can ensure a seamless deployment of their application.
All information was referenced from internal documentation files associated with the project.