Bike Rental Shop Packaging
Package the BikeRentalShop backend or web client into a .krpack so the sample is ready to move from a repository checkout into a deployment workflow.
Full source
Files:
pwsh/tutorial/examples/BikeRentalShop/README.mdpwsh/tutorial/examples/BikeRentalShop/Synchronized/Service.psd1pwsh/tutorial/examples/BikeRentalShop/Concurrent/Service.psd1pwsh/tutorial/examples/BikeRentalShop/Web/Service.psd1
Import-Module .\src\PowerShell\Kestrun\Kestrun.psm1 -Force
New-KrServicePackage -SourceFolder .\docs\_includes\examples\pwsh\BikeRentalShop\Synchronized `
-OutputPath .\artifacts\tutorial\bike-rental-shop.krpack `
-Force
New-KrServicePackage -SourceFolder .\docs\_includes\examples\pwsh\BikeRentalShop\Concurrent `
-OutputPath .\artifacts\tutorial\bike-rental-shop-concurrent.krpack `
-Force
New-KrServicePackage -SourceFolder .\docs\_includes\examples\pwsh\BikeRentalShop\Web `
-OutputPath .\artifacts\tutorial\bike-rental-shop-web.krpack `
-Force
Step-by-step
- Module import: Import the local
Kestrun.psm1module soNew-KrServicePackageis available from the repository checkout. - Source folders: Package
Synchronized/,Concurrent/, andWeb/directly from the BikeRentalShop tutorial example. - Descriptor reuse:
New-KrServicePackage -SourceFolderuses each folder’s checked-inService.psd1for the service name, entry point, and log path. - Output location: Write
.krpackfiles underartifacts/tutorial/or any output path you want for later deployment. - Three targets: Build one package for each BikeRentalShop example so the backend variants and the web client keep separate lifecycle artifacts.
- Application data: Each BikeRentalShop descriptor declares
ApplicationDataFolders = 'data/', 'logs/', which keeps state and logs preserved during service updates and drives durable Docker volumes in generated container bundles. - Deployment split: Package the backend and web client separately so browser assets, API state, and service logs stay isolated.
- Operational handoff: The resulting
.krpackfiles can be archived, copied, and installed by whatever deployment flow you use for Kestrun services.
Try it
Import the module and package all three BikeRentalShop examples:
Import-Module .\src\PowerShell\Kestrun\Kestrun.psm1 -Force
New-KrServicePackage -SourceFolder .\docs\_includes\examples\pwsh\BikeRentalShop\Synchronized `
-OutputPath .\artifacts\tutorial\bike-rental-shop.krpack `
-Force
New-KrServicePackage -SourceFolder .\docs\_includes\examples\pwsh\BikeRentalShop\Concurrent `
-OutputPath .\artifacts\tutorial\bike-rental-shop-concurrent.krpack `
-Force
New-KrServicePackage -SourceFolder .\docs\_includes\examples\pwsh\BikeRentalShop\Web `
-OutputPath .\artifacts\tutorial\bike-rental-shop-web.krpack `
-Force
Inspect the generated package files:
Get-ChildItem .\artifacts\tutorial\*.krpack | Select-Object Name, Length, LastWriteTime
Generate a Docker bundle for the web client package:
New-KrDockerDeployment -PackagePath .\artifacts\tutorial\bike-rental-shop-web.krpack `
-OutputPath .\artifacts\tutorial\bike-rental-shop-web-docker `
-Force
What the package keeps
Service.ps1remains the entry point for each packaged service.Service.psd1keeps the service name, version, description, and log path attached to the package.data/andlogs/are declared as application data folders in all three BikeRentalShop descriptors.New-KrDockerDeploymentturns those declared folders into named Docker volumes so BikeRentalShop data and logs survive container replacement.- Backend and web variants stay independent, so you can deploy one without rebuilding the other.
Deployment pattern
- Package the backend variant you want to run in production.
- Package the standalone web client separately if you want the browser UI.
- Keep the backend and web packages on distinct ports or hosts, just as they are during development.
- Preserve each service’s
data/andlogs/folders when you roll out an updated package.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
New-KrServicePackage is not recognized | The Kestrun module was not imported from the repository | Run Import-Module .\src\PowerShell\Kestrun\Kestrun.psm1 -Force before packaging |
| Packaging fails with a missing descriptor error | The selected source folder does not contain Service.psd1 | Use one of the packaged sample folders: Synchronized/, Concurrent/, or Web/ |
| The package is written to an unexpected file name | -OutputPath was omitted and the wrapper used its default target-based name | Pass -OutputPath explicitly when you need a specific artifact name |
| State does not survive service replacement | The deployment flow did not preserve the declared application data folders | Keep each service’s data/ and logs/ folders in place across updates |
References
- New-KrServicePackage
- Bike Rental Shop Application
- Bike Rental Shop Web Client
- Bike Rental Shop Backend Variants
Previous / Next
Previous: Bike Rental Shop Backend Variants Next: Bike Rental Shop Install and Update