Skip to content

Commit

Permalink
updated container-[gcp|azure]-go
Browse files Browse the repository at this point in the history
  • Loading branch information
diana esteves committed May 10, 2024
1 parent 12d1475 commit 84224ba
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 29 deletions.
2 changes: 2 additions & 0 deletions container-azure-go/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
go.work
go.work.sum
12 changes: 6 additions & 6 deletions container-azure-go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module ${PROJECT}
go 1.20

require (
github.com/pulumi/pulumi-azure-native-sdk/containerinstance/v2 v2.1.1
github.com/pulumi/pulumi-azure-native-sdk/containerregistry/v2 v2.1.1
github.com/pulumi/pulumi-azure-native-sdk/resources/v2 v2.0.0
github.com/pulumi/pulumi-random/sdk/v4 v4.8.2
github.com/pulumi/pulumi-docker/sdk/v4 v4.2.3
github.com/pulumi/pulumi/sdk/v3 v3.96.1
github.com/pulumi/pulumi-azure-native-sdk/containerinstance/v2 v2.40.0
github.com/pulumi/pulumi-azure-native-sdk/containerregistry/v2 v2.40.0
github.com/pulumi/pulumi-azure-native-sdk/resources/v2 v2.40.0
github.com/pulumi/pulumi-docker-build/sdk/go/dockerbuild v0.0.0-20240501144927-9b789f374285
github.com/pulumi/pulumi-random/sdk/v4 v4.16.1
github.com/pulumi/pulumi/sdk/v3 v3.115.2
)
28 changes: 17 additions & 11 deletions container-azure-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/pulumi/pulumi-azure-native-sdk/containerinstance/v2"
"github.com/pulumi/pulumi-azure-native-sdk/containerregistry/v2"
"github.com/pulumi/pulumi-azure-native-sdk/resources/v2"
"github.com/pulumi/pulumi-docker/sdk/v4/go/docker"
"github.com/pulumi/pulumi-docker-build/sdk/go/dockerbuild"
"github.com/pulumi/pulumi-random/sdk/v4/go/random"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
Expand Down Expand Up @@ -70,17 +70,23 @@ func main() {
registryPassword := credentials.Passwords().Index(pulumi.Int(0)).Value().Elem()

// Create a container image for the service.
image, err := docker.NewImage(ctx, "image", &docker.ImageArgs{
ImageName: pulumi.Sprintf("%s/%s:%s", registry.LoginServer, imageName, imageTag),
Build: docker.DockerBuildArgs{
Context: pulumi.String(appPath),
Platform: pulumi.String("linux/amd64"),
image, err := dockerbuild.NewImage(ctx, "image", &dockerbuild.ImageArgs{
Push: pulumi.Bool(true),
Tags: pulumi.StringArray{
pulumi.Sprintf("%s/%s:%s", registry.LoginServer, imageName, imageTag),
},
Registry: docker.RegistryArgs{
Server: registry.LoginServer,
Username: registryUsername,
Password: registryPassword,
Context: &dockerbuild.BuildContextArgs{
Location: pulumi.String(appPath),
},
Platforms: dockerbuild.PlatformArray{
dockerbuild.Platform_Linux_amd64,
},
Registries: dockerbuild.RegistryArray{
&dockerbuild.RegistryArgs{
Address: registry.LoginServer,
Username: registryUsername,
Password: registryPassword,
}},
})
if err != nil {
return err
Expand Down Expand Up @@ -113,7 +119,7 @@ func main() {
Containers: containerinstance.ContainerArray{
containerinstance.ContainerArgs{
Name: pulumi.String(imageName),
Image: image.ImageName,
Image: image.Ref,
Ports: containerinstance.ContainerPortArray{
containerinstance.ContainerPortArgs{
Port: pulumi.Int(containerPort),
Expand Down
2 changes: 2 additions & 0 deletions container-gcp-go/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
go.work
go.work.sum
3 changes: 2 additions & 1 deletion container-gcp-go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module ${PROJECT}
go 1.20

require (
github.com/pulumi/pulumi-docker-build/sdk/go/dockerbuild v0.0.0-20240501144927-9b789f374285
github.com/pulumi/pulumi-gcp/sdk/v7 v7.0.0
github.com/pulumi/pulumi-random/sdk/v4 v4.13.2
github.com/pulumi/pulumi/sdk/v3 v3.91.1
github.com/pulumi/pulumi/sdk/v3 v3.113.3
)
22 changes: 12 additions & 10 deletions container-gcp-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"strconv"

"github.com/pulumi/pulumi-docker/sdk/v4/go/docker"
"github.com/pulumi/pulumi-docker-build/sdk/go/dockerbuild"
"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/artifactregistry"
"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/cloudrun"
"github.com/pulumi/pulumi-random/sdk/v4/go/random"
Expand Down Expand Up @@ -76,14 +76,16 @@ func main() {
// Create a container image for the service.
// Before running `pulumi up`, configure Docker for authentication to Artifact Registry as
// described here: https://cloud.google.com/artifact-registry/docs/docker/authentication
image, err := docker.NewImage(ctx, "image", &docker.ImageArgs{
Registry: docker.RegistryArgs{},
ImageName: pulumi.Sprintf("%s/%s", repoUrl, imageName),
Build: docker.DockerBuildArgs{
Context: pulumi.String(appPath),
// Cloud Run currently requires x86_64 images
// https://cloud.google.com/run/docs/container-contract#languages
Platform: pulumi.String("linux/amd64"),
image, err := dockerbuild.NewImage(ctx, "image", &dockerbuild.ImageArgs{
Push: pulumi.Bool(true),
Tags: pulumi.StringArray{
pulumi.Sprintf("%s/%s", repoUrl, imageName)
},
Context: &dockerbuild.BuildContextArgs{
Location: pulumi.String(appPath),
},
Platforms: dockerbuild.PlatformArray{
dockerbuild.Platform_Linux_amd64,
},
})
if err != nil {
Expand All @@ -97,7 +99,7 @@ func main() {
Spec: cloudrun.ServiceTemplateSpecArgs{
Containers: cloudrun.ServiceTemplateSpecContainerArray{
cloudrun.ServiceTemplateSpecContainerArgs{
Image: image.RepoDigest.Elem(),
Image: image.Ref,
Resources: cloudrun.ServiceTemplateSpecContainerResourcesArgs{
Limits: pulumi.ToStringMap(map[string]string{
"memory": memory,
Expand Down
2 changes: 1 addition & 1 deletion container-gcp-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "${PROJECT}",
"main": "index.ts",
"devDependencies": {
"@types/node": "^18.19.33",
"@types/node": "^18.0.0",
"typescript": "^5.4.5"
},
"dependencies": {
Expand Down

0 comments on commit 84224ba

Please sign in to comment.