Skip to content

Commit

Permalink
Make image tag configurable, templatize package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
cnunciato committed Oct 20, 2022
1 parent 24d805f commit 4a593de
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion container-azure-csharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
var config = new Config();
var appPath = config.Get("appPath") ?? "./app";
var imageName = config.Get("imageName") ?? "my-app";
var imageTag = config.Get("imageTag") ?? "latest";
var containerPort = config.GetInt32("containerPort") ?? 80;
var cpu = config.GetInt32("cpu") ?? 1;
var memory = config.GetInt32("memory") ?? 2;
Expand Down Expand Up @@ -40,7 +41,7 @@
// Create a container image for the service.
var image = new Docker.Image("image", new()
{
ImageName = Pulumi.Output.Format($"{registry.LoginServer}/{imageName}"),
ImageName = Pulumi.Output.Format($"{registry.LoginServer}/{imageName}:{imageTag}"),
Build = new Docker.DockerBuild {
Context = appPath,
},
Expand Down
6 changes: 5 additions & 1 deletion container-azure-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ func main() {
if param := cfg.Get("imageName"); param != "" {
imageName = param
}
imageTag := "latest"
if param := cfg.Get("imageTag"); param != "" {
imageName = param
}
containerPort := 80
if param := cfg.GetInt("containerPort"); param != 0 {
containerPort = param
Expand Down Expand Up @@ -67,7 +71,7 @@ func main() {

// Create a container image for the service.
image, err := docker.NewImage(ctx, "image", &docker.ImageArgs{
ImageName: pulumi.Sprintf("%s/%s", registry.LoginServer, imageName),
ImageName: pulumi.Sprintf("%s/%s:%s", registry.LoginServer, imageName, imageTag),
Build: docker.DockerBuildArgs{
Context: pulumi.String(appPath),
},
Expand Down
3 changes: 2 additions & 1 deletion container-azure-python/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
config = pulumi.Config()
app_path = config.get("appPath", "./app")
image_name = config.get("imageName", "my-app")
image_tag = config.get("imageTag", "latest")
container_port = config.get_int("containerPort", 80)
cpu = config.get_int("cpu", 1)
memory = config.get_int("memory", 2)
Expand Down Expand Up @@ -38,7 +39,7 @@
# Create a container image for the service.
image = docker.Image(
"image",
image_name=pulumi.Output.concat(registry.login_server, "/", image_name),
image_name=pulumi.Output.concat(registry.login_server, f"/{image_name}:{image_tag}"),
build=docker.DockerBuild(
context=app_path,
),
Expand Down
3 changes: 2 additions & 1 deletion container-azure-typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as docker from "@pulumi/docker";
const config = new pulumi.Config();
const appPath = config.get("appPath") || "./app";
const imageName = config.get("imageName") || "my-app";
const imageTag = config.get("imageTag") || "latest";
const containerPort = config.getNumber("containerPort") || 80;
const cpu = config.getNumber("cpu") || 1;
const memory = config.getNumber("memory") || 2;
Expand Down Expand Up @@ -38,7 +39,7 @@ const credentials = containerregistry.listRegistryCredentialsOutput({

// Create a container image for the service.
const image = new docker.Image("image", {
imageName: pulumi.interpolate`${registry.loginServer}/${imageName}`,
imageName: pulumi.interpolate`${registry.loginServer}/${imageName}:${imageTag}`,
build: {
context: appPath,
},
Expand Down
3 changes: 1 addition & 2 deletions container-azure-typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "azure-container",
"main": "index.ts",
"name": "${PROJECT}",
"devDependencies": {
"@types/node": "^14"
},
Expand Down

0 comments on commit 4a593de

Please sign in to comment.