11using Aspire . Hosting . ApplicationModel ;
2- using DotNet . Testcontainers . Builders ;
2+
33using InfinityFlow . Aspire . Temporal ;
44
55namespace 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