From 32cd9989efbe9cf6a2885930752fb1ce97a8c438 Mon Sep 17 00:00:00 2001 From: Erwin Kramer Date: Fri, 28 Jun 2024 01:42:05 +0200 Subject: [PATCH] add bicep deploy template --- README.md | 4 +++ bicep/environment.yaml | 17 +++++++++++ bicep/main.bicep | 69 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 bicep/environment.yaml create mode 100644 bicep/main.bicep diff --git a/README.md b/README.md index 67cc82e..01c11e7 100644 --- a/README.md +++ b/README.md @@ -241,6 +241,10 @@ $ docker run --name rbaskets -d -p 55555:55555 request-baskets $ docker logs rbaskets ``` +### Run container in Azure + +See [bicep folder](./bicep) to deploy the container inside an Azure App Service with [Bicep](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/overview?tabs=bicep). This folder structure also supports [Azure Deployment Environments](https://learn.microsoft.com/en-us/azure/deployment-environments/overview-what-is-azure-deployment-environments). + ### Cleanup Stop and delete docker container: diff --git a/bicep/environment.yaml b/bicep/environment.yaml new file mode 100644 index 0000000..f7b5445 --- /dev/null +++ b/bicep/environment.yaml @@ -0,0 +1,17 @@ +# yaml-language-server: $schema=https://github.com/Azure/deployment-environments/releases/download/2022-11-11-preview/manifest.schema.json +name: BasketApp +summary: Deploy the Request Basket container app. +description: Deploys a Container App within an App Service. +templatePath: main.bicep +runner: Bicep +parameters: + - id: "projectName" + name: "Project Name" + description: "The basket project name" + type: "string" + default: "hellobasket" + - id: "basketAdminToken" + name: "Basket Admin Token" + description: "The Basket Admin Token" + type: "string" + default: "yolo" diff --git a/bicep/main.bicep b/bicep/main.bicep new file mode 100644 index 0000000..c26a0f8 --- /dev/null +++ b/bicep/main.bicep @@ -0,0 +1,69 @@ +/* + +az login +az deployment group create --resource-group ... --template-file main.bicep --parameters basketAdminPassword=yolo + +*/ + +param location string = 'westeurope' +param projectName string = 'helloAzure' +param basketAdminToken string + +resource appServicePlan 'Microsoft.Web/serverfarms@2023-12-01' = { + name: 'plan-baskets-${projectName}-001' + location: location + kind: 'linux' + properties: { + reserved: true + } + sku: { + name: 'F1' + tier: 'Free' + } +} + +resource webApp 'Microsoft.Web/sites@2023-12-01' = { + name: 'app-baskets-${projectName}-001' + location: location + properties: { + serverFarmId: appServicePlan.id + siteConfig: { + linuxFxVersion: 'DOCKER|index.docker.io/darklynx/request-baskets' + appSettings: [ + { + name: 'DOCKER_REGISTRY_SERVER_PASSWORD' + value: 'xxxxx' + } + { + name: 'DOCKER_REGISTRY_SERVER_URL' + value: 'https://index.docker.io' + } + //following settings are for the container itself, please see: https://github.com/darklynx/request-baskets?tab=readme-ov-file#parameters + { + name: 'MAXSIZE' //maximum allowed basket capacity, basket capacity greater than this number will be rejected by service + value: '77777' + } + { + name: 'TOKEN' // master token to gain control over all baskets, if not defined a random token will be generated when service is launched and printed to stdout + value: basketAdminToken + } + { + name: 'BASKET' //name of a basket to auto-create during service startup, this parameter can be specified multiple times + value: 'helloBasket' + } + { + name: 'MODE' //defines service operation mode: public - when any visitor can create a new basket, or restricted - baskets creation requires master token + value: 'public' + } + { + name: 'THEME' //CSS theme for web UI, supported values: standard, adaptive, flatly + value: 'flatly' + } + { + name: 'PAGE' //default page size when retrieving collections + value: '77777' + } + ] + } + } +}