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:

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

  1. Module import: Import the local Kestrun.psm1 module so New-KrServicePackage is available from the repository checkout.
  2. Source folders: Package Synchronized/, Concurrent/, and Web/ directly from the BikeRentalShop tutorial example.
  3. Descriptor reuse: New-KrServicePackage -SourceFolder uses each folder’s checked-in Service.psd1 for the service name, entry point, and log path.
  4. Output location: Write .krpack files under artifacts/tutorial/ or any output path you want for later deployment.
  5. Three targets: Build one package for each BikeRentalShop example so the backend variants and the web client keep separate lifecycle artifacts.
  6. 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.
  7. Deployment split: Package the backend and web client separately so browser assets, API state, and service logs stay isolated.
  8. Operational handoff: The resulting .krpack files 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.ps1 remains the entry point for each packaged service.
  • Service.psd1 keeps the service name, version, description, and log path attached to the package.
  • data/ and logs/ are declared as application data folders in all three BikeRentalShop descriptors.
  • New-KrDockerDeployment turns 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

  1. Package the backend variant you want to run in production.
  2. Package the standalone web client separately if you want the browser UI.
  3. Keep the backend and web packages on distinct ports or hosts, just as they are during development.
  4. Preserve each service’s data/ and logs/ 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


Previous / Next

Previous: Bike Rental Shop Backend Variants Next: Bike Rental Shop Install and Update