Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions playground/withdockerfile/WithDockerfile.AppHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
{
var timestamp = DateTime.Now.ToString("yyyyMMddHHmmss", System.Globalization.CultureInfo.InvariantCulture);
return $"""
FROM golang:1.22-alpine AS builder
FROM mcr.microsoft.com/oss/go/microsoft/golang:1.23 AS builder
WORKDIR /app
COPY . .
RUN echo "Built at {timestamp}" > /build-info.txt
RUN go build -o qots .

FROM alpine:latest
FROM mcr.microsoft.com/cbl-mariner/base/core:2.0
COPY --from=builder /app/qots /qots
COPY --from=builder /build-info.txt /build-info.txt
ENTRYPOINT ["/qots"]
Expand All @@ -41,20 +41,21 @@ ENTRYPOINT ["/qots"]
{
// Simulate reading from a template or external source
await Task.Delay(1, context.CancellationToken);
var baseImage = Environment.GetEnvironmentVariable("BASE_IMAGE") ?? "golang:1.22-alpine";
var baseImage = Environment.GetEnvironmentVariable("BASE_IMAGE") ?? "mcr.microsoft.com/oss/go/microsoft/golang:1.23";
return $"""
FROM {baseImage} AS builder
WORKDIR /app
COPY . .
RUN go build -o qots .

FROM alpine:latest
FROM mcr.microsoft.com/cbl-mariner/base/core:2.0
COPY --from=builder /app/qots /qots
ENTRYPOINT ["/qots"]
""";
});

builder.AddRedis("builder-sync")
.WithImageRegistry("netaspireci.azurecr.io")
.WithDockerfileBuilder(".", context =>
{
if (!context.Resource.TryGetContainerImageName(useBuiltImage: false, out var imageName))
Expand All @@ -66,6 +67,7 @@ ENTRYPOINT ["/qots"]
});

builder.AddRedis("builder-async")
.WithImageRegistry("netaspireci.azurecr.io")
.WithDockerfileBuilder(".", async context =>
{
await Task.Delay(1, context.CancellationToken);
Expand Down