Skip to content

Commit 24e4064

Browse files
authored
Speed up Startup Time: Use temporalio/admin-tools:latest instead of building our own.
1 parent e50c165 commit 24e4064

File tree

2 files changed

+3
-75
lines changed

2 files changed

+3
-75
lines changed

src/InfinityFlow.Aspire.Temporal/InfinityFlow.Aspire.Temporal.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,5 @@
3030
<ItemGroup>
3131
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
3232
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.1.0" />
33-
<PackageReference Include="Docker.DotNet" Version="3.125.15" />
34-
<PackageReference Include="Testcontainers" Version="4.3.0" />
3533
</ItemGroup>
3634
</Project>
Lines changed: 3 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Aspire.Hosting.ApplicationModel;
2-
using DotNet.Testcontainers.Builders;
2+
33
using InfinityFlow.Aspire.Temporal;
44

55
namespace Aspire.Hosting;
@@ -32,52 +32,14 @@ public static Task<IResourceBuilder<TemporalServerContainerResource>> AddTempora
3232
{
3333
return builder.AddTemporalServerContainer(name, new TemporalServerResourceArguments());
3434
}
35-
36-
const string Dockerfile = """
37-
# Define the build stage
38-
FROM alpine as builder
39-
40-
# Install curl and tar
41-
RUN apk add --no-cache curl tar
42-
43-
# Set build arguments for URL, defaulting ARCH to amd64
44-
ARG ARCH=amd64
45-
ARG URL="https://temporal.download/cli/archive/latest?platform=linux"
46-
47-
# Download the binary based on the architecture
48-
RUN curl -L "${URL}&arch=${ARCH}" -o temporal.tar.gz
49-
50-
# Extract the archive
51-
RUN tar -xzf temporal.tar.gz -C /tmp
52-
RUN mv /tmp/temporal /temporal
53-
54-
# Ensure the binary is executable
55-
RUN chmod +x /temporal
56-
57-
# Define the final stage based on a scratch image for minimal size
58-
FROM alpine
59-
60-
# Copy the binary from the builder stage
61-
COPY --from=builder /temporal /temporal
62-
63-
EXPOSE 7233
64-
EXPOSE 8233
65-
EXPOSE 7235
66-
EXPOSE 7234
67-
68-
# Set the entrypoint to the downloaded binary
69-
ENTRYPOINT ["/temporal"]
70-
""";
71-
7235
private static async Task<IResourceBuilder<TemporalServerContainerResource>> AddTemporalServerContainer(this IDistributedApplicationBuilder builder, string name, TemporalServerResourceArguments args)
7336
{
74-
await BuildAspireHelperContainer();
75-
7637
var container = new TemporalServerContainerResource(name, args);
7738

7839
var resourceBuilder = builder.AddResource(container)
79-
.WithAnnotation(new ContainerImageAnnotation() { Image = "aspire-temporal-server-helper", Tag = "latest" })
40+
.WithAnnotation(new ContainerImageAnnotation() { Image = "temporalio/admin-tools", Tag = "latest" })
8041
.WithArgs(args.GetArgs())
42+
.WithEntrypoint("temporal")
8143
.WithHttpsEndpoint(name: "server", port: args.Port, targetPort: 7233).AsHttp2Service(); // Internal port is always 7233
8244

8345
if (args.Headless is not true)
@@ -97,36 +59,4 @@ private static async Task<IResourceBuilder<TemporalServerContainerResource>> Add
9759

9860
return resourceBuilder;
9961
}
100-
101-
private static async Task BuildAspireHelperContainer()
102-
{
103-
string tempDir = string.Empty;
104-
try
105-
{
106-
tempDir = Directory.CreateTempSubdirectory("aspire-temporal-server").FullName;
107-
var dockerFileTemp = Path.Join(tempDir, "Dockerfile");
108-
109-
await File.WriteAllTextAsync(dockerFileTemp, Dockerfile);
110-
111-
await using var futureImage = new ImageFromDockerfileBuilder()
112-
.WithDockerfileDirectory(tempDir)
113-
.WithDeleteIfExists(false)
114-
.WithBuildArgument("ARCH", System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture switch
115-
{
116-
System.Runtime.InteropServices.Architecture.X64 => "amd64",
117-
System.Runtime.InteropServices.Architecture.Arm64 => "arm64",
118-
_ => throw new NotImplementedException($"Unsupported CPU Architecture: {System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture}")
119-
})
120-
.WithBuildArgument("URL", "https://temporal.download/cli/archive/latest?platform=linux")
121-
.WithName("aspire-temporal-server-helper:latest")
122-
.WithDockerfile("Dockerfile")
123-
.Build();
124-
125-
await futureImage.CreateAsync();
126-
}
127-
finally
128-
{
129-
Directory.Delete(tempDir, true);
130-
}
131-
}
13262
}

0 commit comments

Comments
 (0)