https://pulumi.com logo
#getting-started
Title
# getting-started
b

breezy-agency-13977

12/19/2023, 4:21 PM
How do I get my cloud run to deploy every time I push up a new image? Right now I am using the imageName but it doesn't deploy a new revision unless I change something else within the cloud run service. Here is what mine looks like currently.
Copy code
service, err := cloudrun.NewService(ctx, appName, &cloudrun.ServiceArgs{
			Location: pulumi.String(region),
			Project:  pulumi.String(projectID),
			Name:     pulumi.String(appName),
			Template: &cloudrun.ServiceTemplateArgs{
				Spec: &cloudrun.ServiceTemplateSpecArgs{
					Containers: cloudrun.ServiceTemplateSpecContainerArray{
						&cloudrun.ServiceTemplateSpecContainerArgs{
							Image: appImage.ImageName,
							Ports: cloudrun.ServiceTemplateSpecContainerPortArray{
								&cloudrun.ServiceTemplateSpecContainerPortArgs{
									Name:          pulumi.String("http1"),
									ContainerPort: <http://pulumi.Int|pulumi.Int>(8080),
								},
							},
							Resources: &cloudrun.ServiceTemplateSpecContainerResourcesArgs{
								Limits: pulumi.StringMap(map[string]pulumi.StringInput{
									"cpu":    pulumi.String("1"),
									"memory": pulumi.String("512Mi"),
								}),
							},
						},
					},
					ContainerConcurrency: <http://pulumi.Int|pulumi.Int>(5),
				},
			},
			Traffics: cloudrun.ServiceTrafficArray{
				&cloudrun.ServiceTrafficArgs{
					Percent:        <http://pulumi.Int|pulumi.Int>(100),
					LatestRevision: pulumi.Bool(true),
				},
			},
		}, pulumi.DependsOn([]pulumi.Resource{appImage}))
		if err != nil {
			return err
		}
d

dry-keyboard-94795

12/19/2023, 4:25 PM
Use the image hash instead of the name. What's
appImage
in your example?
b

breezy-agency-13977

12/19/2023, 4:29 PM
Copy code
appImage, err := docker.NewImage(ctx, appName, &docker.ImageArgs{
			ImageName: pulumi.Sprintf("%s-docker.pkg.dev/%s/%s/api", region, projectID, appName),
			Build: &docker.DockerBuildArgs{
				Context:    pulumi.String("./"),
				Dockerfile: pulumi.String("./Dockerfile"),
				Platform:   pulumi.String("linux/amd64"),
			}})
How do I get the image hash from here?
d

dry-keyboard-94795

12/19/2023, 4:30 PM
b

breezy-agency-13977

12/19/2023, 7:34 PM
I think that worked. Thanks Anthony!
2 Views