Skip to content

Commit 01c570d

Browse files
committed
Updating to fix DockerBuild Settings, Fixes #1869
1 parent d53fcce commit 01c570d

File tree

4 files changed

+51
-42
lines changed

4 files changed

+51
-42
lines changed

aws-py-voting-app/__main__.py

+15-16
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pulumi
77
import pulumi_aws as aws
88
import pulumi_docker as docker
9+
import pulumi_docker_build as docker_build
910

1011
# Get the password to use for Redis from the pulumi config
1112
config = pulumi.Config()
@@ -143,10 +144,6 @@
143144
port=redis_port,
144145
protocol="TCP",
145146
target_type="ip",
146-
stickiness=aws.lb.TargetGroupStickinessArgs(
147-
enabled=False,
148-
type="lb_cookie",
149-
),
150147
vpc_id=app_vpc.id,
151148
)
152149

@@ -235,10 +232,6 @@
235232
port=80,
236233
protocol="TCP",
237234
target_type="ip",
238-
stickiness=aws.lb.TargetGroupStickinessArgs(
239-
enabled=False,
240-
type="lb_cookie",
241-
),
242235
vpc_id=app_vpc.id,
243236
)
244237

@@ -271,17 +264,23 @@ def get_registry_info(rid):
271264
parts = decoded.split(":")
272265
if len(parts) != 2:
273266
raise Exception("Invalid credentials")
274-
return docker.ImageRegistry(creds.proxy_endpoint, parts[0], parts[1])
267+
return docker_build.RegistryArgs(
268+
address=creds.proxy_endpoint, username=parts[0], password=parts[1]
269+
)
275270

276271

277272
app_registry = app_ecr_repo.registry_id.apply(get_registry_info)
278273

279-
flask_image = docker.Image(
274+
flask_image_dockerbuild = docker_build.Image(
280275
"flask-dockerimage",
281-
image_name=app_ecr_repo.repository_url,
282-
build="./frontend",
283-
skip_push=False,
284-
registry=app_registry,
276+
tags=[
277+
app_ecr_repo.repository_url.apply(lambda repository_url: f"{repository_url}:latest"),
278+
],
279+
context=docker_build.BuildContextArgs(
280+
location="./frontend",
281+
),
282+
push=True,
283+
registries=[app_registry],
285284
)
286285

287286
# Creating a task definition for the Flask instance.
@@ -298,15 +297,15 @@ def get_registry_info(rid):
298297
[
299298
{
300299
"name": "flask-container",
301-
"image": flask_image.image_name,
300+
"image": flask_image_dockerbuild.ref,
302301
"memory": 512,
303302
"essential": True,
304303
"portMappings": [{"containerPort": 80, "hostPort": 80, "protocol": "tcp"}],
305304
"environment": [ # The Redis endpoint we created is given to Flask, allowing it to communicate with the former
306305
{"name": "REDIS", "value": redis_endpoint["host"]},
307306
{
308307
"name": "REDIS_PORT",
309-
"value": redis_endpoint["port"].apply(lambda x: str(x)),
308+
"value": pulumi.Output.concat(str(redis_endpoint["port"])),
310309
},
311310
{"name": "REDIS_PWD", "value": redis_password},
312311
],

aws-py-voting-app/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
pulumi>=3.5.1,<4.0.0
22
pulumi-aws>=6.0.2,<7.0.0
33
pulumi-docker>=4.6.0,<4.7.0
4+
pulumi-docker-build>=0.0.10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
5-
<TargetFramework>net8.0</TargetFramework>
6-
<Nullable>enable</Nullable>
7-
</PropertyGroup>
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
88

9-
<ItemGroup>
10-
<PackageReference Include="Pulumi" Version="3.*" />
11-
<PackageReference Include="Pulumi.AzureNative" Version="2.*" />
12-
<PackageReference Include="Pulumi.Docker" Version="4.*" />
13-
<PackageReference Include="Pulumi.Random" Version="4.*" />
14-
</ItemGroup>
9+
<ItemGroup>
10+
<PackageReference Include="Pulumi" Version="3.*" />
11+
<PackageReference Include="Pulumi.AzureNative" Version="2.*" />
12+
<PackageReference Include="Pulumi.DockerBuild" Version="0.0.10" />
13+
<PackageReference Include="Pulumi.Random" Version="4.*" />
14+
</ItemGroup>
1515

1616
</Project>

azure-cs-appservice-docker/MyStack.cs

+24-15
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
using Pulumi.AzureNative.Resources;
77
using Pulumi.AzureNative.Web;
88
using Pulumi.AzureNative.Web.Inputs;
9-
using Pulumi.Docker;
10-
using Pulumi.Random;
9+
using DockerBuild = Pulumi.DockerBuild;
10+
1111

1212
class MyStack : Stack
1313
{
@@ -61,31 +61,40 @@ public MyStack()
6161
//
6262
var customImage = "node-app";
6363

64-
var registry = new Registry("myregistry", new RegistryArgs
64+
var registry = new Registry("myregistry", new Pulumi.AzureNative.ContainerRegistry.RegistryArgs
6565
{
6666
ResourceGroupName = resourceGroup.Name,
6767
Sku = new SkuArgs { Name = "Basic" },
6868
AdminUserEnabled = true
6969
});
7070

7171
var credentials = ListRegistryCredentials.Invoke(new ListRegistryCredentialsInvokeArgs
72-
{
73-
ResourceGroupName = resourceGroup.Name,
74-
RegistryName = registry.Name
75-
});
72+
{
73+
ResourceGroupName = resourceGroup.Name,
74+
RegistryName = registry.Name
75+
});
7676
var adminUsername = credentials.Apply(c => c.Username ?? "");
7777
var adminPassword = credentials.Apply(c => Output.CreateSecret(c.Passwords.First().Value ?? ""));
7878

79-
var myImage = new Image(customImage, new ImageArgs
79+
var myImage = new DockerBuild.Image(customImage, new Pulumi.DockerBuild.ImageArgs
8080
{
81-
ImageName = Output.Format($"{registry.LoginServer}/{customImage}:v1.0.0"),
82-
Build = new DockerBuild { Context = $"./{customImage}" },
83-
Registry = new ImageRegistry
81+
Context = new DockerBuild.Inputs.BuildContextArgs
8482
{
85-
Server = registry.LoginServer,
86-
Username = adminUsername,
87-
Password = adminPassword
83+
Location = $"./{customImage}",
8884
},
85+
Tags = new[]
86+
{
87+
Output.Format($"{registry.LoginServer}/{customImage}:v1.0.0"),
88+
},
89+
Push = true,
90+
Registries = new[]{
91+
new DockerBuild.Inputs.RegistryArgs
92+
{
93+
Address = registry.LoginServer,
94+
Username = adminUsername,
95+
Password = adminPassword,
96+
}
97+
}
8998
});
9099

91100
var getStartedApp = new WebApp("get-started", new WebAppArgs
@@ -123,7 +132,7 @@ public MyStack()
123132
}
124133
},
125134
AlwaysOn = true,
126-
LinuxFxVersion = Output.Format($"DOCKER|{myImage.ImageName}")
135+
LinuxFxVersion = Output.Format($"DOCKER|{myImage.Ref}")
127136
},
128137
HttpsOnly = true
129138
});

0 commit comments

Comments
 (0)