This repository demonstrates the dstack launcher pattern - a template for implementing automated container updates in your applications.
The launcher pattern is a containerized approach to managing application updates. It consists of:
- A launcher container that runs continuously and checks for updates
- A workload container that is the actual application being managed
The launcher container periodically checks for updates to the workload container and automatically deploys new versions when they become available.
This example project demonstrates the basic structure of the launcher pattern:
Dockerfile: Builds the launcher container with necessary dependenciesentrypoint.sh: The main script that runs inside the launcher container, checking for updates and deploying new versionsget-latest.sh: A script that determines the latest version of the workload container (in a real implementation, this would typically check a registry or other source)docker-compose.yml: Example configuration for running the launcher container
This project is intended as a starting point. To adapt it for your own use:
- Modify
get-latest.shto implement your own version checking logic (e.g., checking a container registry) - Adjust the configuration variables in
entrypoint.shto match your application needs - Update the
docker-compose.ymlfile with any additional configuration your launcher needs
The update process follows these steps:
- The launcher container runs
get-latest.shto determine the latest available version - If a new version is detected, it generates a new
docker-compose.ymlfile for the workload - It applies the new configuration using Docker Compose, which pulls and starts the new container
- The process repeats on a regular interval
Key areas to customize for your own implementation:
- Version Detection: Replace the logic in
get-latest.shwith your own mechanism for determining the latest version - Deployment Configuration: Modify how the
docker-compose.ymlis generated inentrypoint.sh - Update Frequency: Adjust the sleep interval in the main loop of
entrypoint.sh - Additional Logic: Add pre/post update hooks, validation, or other custom logic
- Build the launcher container:
./build-image.sh yourusername/launcher- Push the image to Docker Hub (recommended for production use):
docker push yourusername/launcher- Deploy
You can now deploy the following compose to dstack or Phala Cloud.
services:
launcher:
image: yourusername/launcher
volumes:
- /var/run/docker.sock:/var/run/docker.sock
restart: alwaysNote: The example configuration above uses a placeholder yourusername/launcher as the image name. Make sure to update it with your actual published image name.
MIT License
Copyright (c) 2025
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.