Skip to content

Commit

Permalink
Make CPU and memory configurable in the TS template
Browse files Browse the repository at this point in the history
  • Loading branch information
cnunciato committed Oct 20, 2022
1 parent 197ac7b commit a413692
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
3 changes: 3 additions & 0 deletions container-azure-csharp/Pulumi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ template:
azure-native:location:
description: The Azure region to deploy into
default: WestUS
appName:
description: The name of the application to deploy
default: my-app
appPath:
description: The path to the container application to deploy
default: app
Expand Down
8 changes: 4 additions & 4 deletions container-azure-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ func main() {

// Import the program's configuration settings.
cfg := config.New(ctx, "")
imageName := "my-app"
if param := cfg.Get("imageName"); param != "" {
imageName = param
}
appPath := "./app"
if param := cfg.Get("appPath"); param != "" {
appPath = param
}
imageName := "my-app"
if param := cfg.Get("imageName"); param != "" {
imageName = param
}
containerPort := 80
if param := cfg.GetInt("containerPort"); param != 0 {
containerPort = param
Expand Down
2 changes: 1 addition & 1 deletion container-azure-python/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

# Import the program's configuration settings.
config = pulumi.Config()
image_name = config.get("imageName", "my-app")
app_path = config.get("appPath", "./app")
image_name = config.get("imageName", "my-app")
container_port = config.get_int("containerPort", 80)
cpu = config.get_float("cpu", 1.0)
memory = config.get_float("memory", 1.5)
Expand Down
8 changes: 5 additions & 3 deletions container-azure-typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import * as docker from "@pulumi/docker";

// Import the program's configuration settings.
const config = new pulumi.Config();
const imageName = config.get("imageName") || "my-app";
const appPath = config.get("appPath") || "./app";
const imageName = config.get("imageName") || "my-app";
const containerPort = config.getNumber("containerPort") || 80;
const cpu = config.getNumber("cpu") || 1.0;
const memory = config.getNumber("memory") || 1.5;

// Create a resource group for the container registry.
const resourceGroup = new resources.ResourceGroup("resource-group");
Expand Down Expand Up @@ -83,8 +85,8 @@ const containerGroup = new containerinstance.ContainerGroup("container-group", {
],
resources: {
requests: {
cpu: 1.0,
memoryInGB: 1.5,
cpu: cpu,
memoryInGB: memory,
},
},
},
Expand Down

0 comments on commit a413692

Please sign in to comment.