Blueprints
Multi-cloud deployment pipeline with Docker, ngrok, GCP Cloud Run, and Azure Container Apps
Source
yaml
id: multi-cloud-deployment
namespace: company.team
inputs:
- id: cloud_name
type: SELECT
displayName: Cloud name
description: Available values - local, gcp and azure
required: true
values:
- local
- gcp
- azure
- id: github_repo
type: STRING
displayName: GitHub repository
description: GitHub public repository that has Dockerfile
required: true
defaults: https://github.com/AlapMistry/spring-boot-demo
- id: github_repo_branch
type: STRING
displayName: GitHub repository branch
description: GitHub public repository branch that has Dockerfile
required: true
defaults: main
- id: docker_user_account_name
type: STRING
displayName: Docker Hub user account name
description: Docker Hub user account name
required: true
defaults: alapmistry
- id: docker_image_tag
type: STRING
displayName: Docker image tag
description: Your application docker image tag
required: true
defaults: 1.0.0
- id: application_name
type: STRING
displayName: Application name
description: Your application name that start with lower case letters and
contain numbers and - (hyphen) upto 49 characters length
required: true
defaults: spring-boot-demo
- id: docker_container_port
type: STRING
displayName: Docker container port
description: Your application must run on this port
required: true
defaults: "8080"
- id: host_port
type: STRING
displayName: Host port
description: Your application will expose on this port to the world
required: true
defaults: "8080"
tasks:
- id: docker_image
type: io.kestra.plugin.core.flow.WorkingDirectory
tasks:
- id: clone_repo
type: io.kestra.plugin.git.Clone
url: "{{ inputs.github_repo }}"
branch: "{{ inputs.github_repo_branch }}"
- id: docker_build_push
type: io.kestra.plugin.docker.Build
tags:
- "{{ inputs.docker_user_account_name }}/{{ inputs.application_name
}}:{{ inputs.docker_image_tag }}"
dockerfile: "Dockerfile"
push: true
credentials:
registry: https://index.docker.io/v1/
username: "{{ secret('DOCKER_HUB_USERNAME') }}"
password: "{{ secret('DOCKER_HUB_PAT') }}"
- id: cloud_choice
type: io.kestra.plugin.core.flow.Switch
value: "{{ inputs.cloud_name }}"
cases:
local:
- id: local_docker_run
type: io.kestra.plugin.docker.Run
containerImage: "{{ inputs.docker_user_account_name }}/{{
inputs.application_name }}:{{ inputs.docker_image_tag }}"
pullPolicy: IF_NOT_PRESENT
wait: false
portBindings:
- "{{ inputs.host_port }}:{{ inputs.docker_container_port }}"
- id: local_ngrok_expose
type: io.kestra.plugin.scripts.shell.Commands
targetOS: LINUX
containerImage: ngrok/ngrok:3
taskRunner:
type: io.kestra.plugin.scripts.runner.docker.Docker
networkMode: host
wait: false
env:
NGROK_AUTHTOKEN: "{{ secret('NGROK_AUTH_TOKEN') }}"
commands:
- "ngrok http {{ inputs.host_port }} --url {{
secret('NGROK_STATIC_DOMAIN') }}"
gcp:
- id: gcp_service_deploy
type: io.kestra.plugin.gcp.cli.GCloudCLI
projectId: "{{ secret('GCP_PROJECT_ID') }}"
serviceAccount: "{{ secret('GCP_SERVICE_ACCOUNT') }}"
commands:
- "gcloud run deploy {{ inputs.application_name }}
--image=docker.io/{{ inputs.docker_user_account_name }}/{{
inputs.application_name }}:{{ inputs.docker_image_tag }} --port={{
inputs.docker_container_port }} --region={{ secret('GCP_REGION')
}}"
azure:
- id: azure_service_deploy
type: io.kestra.plugin.azure.cli.AzCLI
username: "{{ secret('AZURE_APP_ID') }}"
password: "{{ secret('AZURE_SERVICE_PRINCIPAL_PASSWORD') }}"
tenant: "{{ secret('AZURE_TENANT_ID') }}"
servicePrincipal: true
commands:
- az container create --resource-group {{
secret('AZURE_RESOURCE_GROUP') }} --name {{
inputs.application_name }} --image docker.io/{{
inputs.docker_user_account_name }}/{{ inputs.application_name
}}:{{ inputs.docker_image_tag }} --dns-name-label {{
inputs.application_name }} --ports {{ inputs.docker_container_port
}} --os-type linux --memory 1.5 --cpu 1 --location {{
secret('AZURE_LOCATION') }}
About this blueprint
CLI DevOps Git GCP Azure
This flow builds and deploys a Dockerized application from a public GitHub repository to your choice of local, GCP, or Azure environments. It uses Docker Hub for image storage, ngrok for exposing local deployments, GCP Cloud Run Service, and Azure Container App.
Required secrets must be provided for Docker Hub, ngrok, GCP, and Azure. For GCP deployments, an identity token is needed to access deployed applications.
After verification, remember to clean up any cloud resources manually to avoid unnecessary charges.