From c41b664af6c486c9fb29e141dc9c9de9750bfe8e Mon Sep 17 00:00:00 2001 From: Paul Yuknewicz Date: Wed, 24 Jul 2024 01:06:06 -0700 Subject: [PATCH] Fixing build.yaml github action workflow with modern dockerfiles. go for dist calculator already fixed by #1058 Signed-off-by: Paul Yuknewicz --- .../distributed-calculator/csharp/Dockerfile | 26 +++++++++++++++---- .../distributed-calculator/node/Dockerfile | 2 +- .../distributed-calculator/python/Dockerfile | 2 +- .../react-calculator/Dockerfile | 2 +- tutorials/hello-kubernetes/node/Dockerfile | 2 +- tutorials/hello-kubernetes/python/Dockerfile | 2 +- tutorials/observability/python/Dockerfile | 2 +- .../pub-sub/csharp-subscriber/Dockerfile | 22 +++++++++++++--- tutorials/pub-sub/node-subscriber/Dockerfile | 2 +- .../pub-sub/python-subscriber/Dockerfile | 2 +- tutorials/pub-sub/react-form/Dockerfile | 2 +- 11 files changed, 49 insertions(+), 17 deletions(-) diff --git a/tutorials/distributed-calculator/csharp/Dockerfile b/tutorials/distributed-calculator/csharp/Dockerfile index 1089c13de..d739dffe3 100644 --- a/tutorials/distributed-calculator/csharp/Dockerfile +++ b/tutorials/distributed-calculator/csharp/Dockerfile @@ -1,7 +1,23 @@ -# Note: we cannot do a staged dotnet docker build here for arm/arm64. +# Use the official .NET 7 SDK image to build the application +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:7.0 AS build +WORKDIR /app + +# Copy the project file and restore dependencies +COPY *.csproj ./ +RUN dotnet clean +RUN dotnet restore --disable-parallel + +# Copy the rest of the application code and build the application +COPY . ./ +RUN dotnet publish -c Release -o out -# Build runtime image -FROM mcr.microsoft.com/dotnet/aspnet:7.0 +# Use the official .NET 7 runtime image to run the application +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:7.0 AS runtime WORKDIR /app -COPY /out . -ENTRYPOINT ["dotnet", "Subtract.dll"] +COPY --from=build /app/out . + +# Expose the port the application runs on +EXPOSE 80 + +# Run the application +ENTRYPOINT ["dotnet", "YourProjectName.dll"] diff --git a/tutorials/distributed-calculator/node/Dockerfile b/tutorials/distributed-calculator/node/Dockerfile index 0c7ab850e..074f773a7 100644 --- a/tutorials/distributed-calculator/node/Dockerfile +++ b/tutorials/distributed-calculator/node/Dockerfile @@ -1,4 +1,4 @@ -FROM node:17-alpine +FROM node:20-alpine WORKDIR /usr/src/app COPY . . RUN npm install diff --git a/tutorials/distributed-calculator/python/Dockerfile b/tutorials/distributed-calculator/python/Dockerfile index fa0d808f5..bb944d8ca 100644 --- a/tutorials/distributed-calculator/python/Dockerfile +++ b/tutorials/distributed-calculator/python/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.7-alpine +FROM python:3.12-alpine COPY . /app WORKDIR /app RUN pip install flask flask_cors diff --git a/tutorials/distributed-calculator/react-calculator/Dockerfile b/tutorials/distributed-calculator/react-calculator/Dockerfile index 945cad5e0..d20b79bd2 100644 --- a/tutorials/distributed-calculator/react-calculator/Dockerfile +++ b/tutorials/distributed-calculator/react-calculator/Dockerfile @@ -1,4 +1,4 @@ -FROM node:17-alpine +FROM node:20-alpine WORKDIR /usr/src/app COPY . . RUN npm install diff --git a/tutorials/hello-kubernetes/node/Dockerfile b/tutorials/hello-kubernetes/node/Dockerfile index 5c3326ea3..68d185a37 100644 --- a/tutorials/hello-kubernetes/node/Dockerfile +++ b/tutorials/hello-kubernetes/node/Dockerfile @@ -1,4 +1,4 @@ -FROM node:17-alpine +FROM node:20-alpine WORKDIR /app COPY . . RUN npm install diff --git a/tutorials/hello-kubernetes/python/Dockerfile b/tutorials/hello-kubernetes/python/Dockerfile index 50e053797..438867fdf 100644 --- a/tutorials/hello-kubernetes/python/Dockerfile +++ b/tutorials/hello-kubernetes/python/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.7-alpine +FROM python:3.12-alpine WORKDIR /app COPY . . RUN pip install requests diff --git a/tutorials/observability/python/Dockerfile b/tutorials/observability/python/Dockerfile index fa0d808f5..bb944d8ca 100644 --- a/tutorials/observability/python/Dockerfile +++ b/tutorials/observability/python/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.7-alpine +FROM python:3.12-alpine COPY . /app WORKDIR /app RUN pip install flask flask_cors diff --git a/tutorials/pub-sub/csharp-subscriber/Dockerfile b/tutorials/pub-sub/csharp-subscriber/Dockerfile index e7c0c2a1b..636084fd8 100644 --- a/tutorials/pub-sub/csharp-subscriber/Dockerfile +++ b/tutorials/pub-sub/csharp-subscriber/Dockerfile @@ -1,6 +1,22 @@ -# Note: we cannot do a staged dotnet docker build here for arm/arm64. +# Use the official .NET 8 SDK image to build the application +FROM --platform=linux/arm64 mcr.microsoft.com/dotnet/sdk:8.0 AS build +WORKDIR /app + +# Copy the project file and restore dependencies +COPY *.csproj ./ +RUN dotnet restore --disable-parallel + +# Copy the rest of the application code and build the application +COPY . ./ +RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:8.0 +# Use the official .NET 8 runtime image to run the application +FROM --platform=linux/arm64 mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime WORKDIR /app -COPY /out . +COPY --from=build /app/out . + +# Expose the port the application runs on +EXPOSE 80 + +# Run the application ENTRYPOINT ["dotnet", "csharp-subscriber.dll"] diff --git a/tutorials/pub-sub/node-subscriber/Dockerfile b/tutorials/pub-sub/node-subscriber/Dockerfile index 939caefb5..40bf18590 100644 --- a/tutorials/pub-sub/node-subscriber/Dockerfile +++ b/tutorials/pub-sub/node-subscriber/Dockerfile @@ -1,4 +1,4 @@ -FROM node:17-alpine +FROM node:20-alpine WORKDIR /usr/src/app COPY . . RUN npm install diff --git a/tutorials/pub-sub/python-subscriber/Dockerfile b/tutorials/pub-sub/python-subscriber/Dockerfile index f45330cf3..dd388c0bb 100644 --- a/tutorials/pub-sub/python-subscriber/Dockerfile +++ b/tutorials/pub-sub/python-subscriber/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.7-alpine +FROM python:3.12-alpine COPY . /app WORKDIR /app RUN pip install flask flask_cors diff --git a/tutorials/pub-sub/react-form/Dockerfile b/tutorials/pub-sub/react-form/Dockerfile index 8d909224b..11b2d2171 100644 --- a/tutorials/pub-sub/react-form/Dockerfile +++ b/tutorials/pub-sub/react-form/Dockerfile @@ -1,4 +1,4 @@ -FROM node:17-alpine +FROM node:20-alpine WORKDIR /usr/src/app COPY . . RUN npm run build