From c214d6c01723b90195940e306a0c5820ed958641 Mon Sep 17 00:00:00 2001 From: Shubham Sharma Date: Mon, 20 Mar 2023 13:40:41 +0530 Subject: [PATCH] Update Windows versions in Dockerfiles for e2e apps (#6060) * Update Windows versions in Dockerfiles for e2e apps Signed-off-by: Shubham Sharma * re-trigger pipeline Signed-off-by: Shubham Sharma * Stop caching temp Signed-off-by: Shubham Sharma * Upgrade dotnet version in actor-dotnet app Signed-off-by: Shubham Sharma * Fix images Signed-off-by: Shubham Sharma * Changes to actorpython Signed-off-by: Shubham Sharma * Update python test Signed-off-by: Shubham Sharma * re-trigger pipeline Signed-off-by: Shubham Sharma * re-trigger pipeline Signed-off-by: Shubham Sharma * re-trigger pipeline Signed-off-by: Shubham Sharma * Update caching in build tools Signed-off-by: Shubham Sharma * re-trigger pipeline Signed-off-by: Shubham Sharma * Add Windows version to makefile Signed-off-by: Shubham Sharma * Add missing '\' Signed-off-by: Shubham Sharma --------- Signed-off-by: Shubham Sharma Co-authored-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> Co-authored-by: Loong Dai --- .build-tools/cmd/zz-e2e-perf.go | 15 +++++++++++++-- tests/apps/Dockerfile-windows | 2 +- tests/apps/actordotnet/CarActor.csproj | 2 +- tests/apps/actordotnet/Dockerfile | 4 ++-- tests/apps/actordotnet/Dockerfile-windows | 4 ++-- tests/apps/actorjava/Dockerfile-windows | 2 +- tests/apps/actorphp/Dockerfile-windows | 2 +- tests/apps/actorpython/Dockerfile | 2 +- tests/apps/actorpython/Dockerfile-windows | 2 +- tests/apps/actorpython/requirements.txt | 3 ++- tests/dapr_tests.mk | 7 ++++++- 11 files changed, 31 insertions(+), 14 deletions(-) diff --git a/.build-tools/cmd/zz-e2e-perf.go b/.build-tools/cmd/zz-e2e-perf.go index 7bd2acb6767..46a46b49d6c 100644 --- a/.build-tools/cmd/zz-e2e-perf.go +++ b/.build-tools/cmd/zz-e2e-perf.go @@ -49,6 +49,7 @@ type cmdE2EPerfFlags struct { IgnoreFile string CacheIncludeFile string Name string + WindowsVersion string } // Returns the command for e2e or perf @@ -91,6 +92,7 @@ If the "--cache-registry" option is set, it will be pushed to the cache too. buildCmd.Flags().StringVar(&obj.flags.TargetArch, "target-arch", runtime.GOARCH, "Target architecture") buildCmd.Flags().StringVar(&obj.flags.IgnoreFile, "ignore-file", ".gitignore", "Name of the file with files to exclude (in the format of .gitignore)") buildCmd.Flags().StringVar(&obj.flags.CacheIncludeFile, "cache-include-file", ".cache-include", "Name of the file inside the app folder with additional files to include in checksumming (in the format of .gitignore)") + buildCmd.Flags().StringVar(&obj.flags.WindowsVersion, "windows-version", "", "Windows version to use for Windows containers") // "push" sub-command pushCmd := &cobra.Command{ @@ -132,6 +134,7 @@ If the "--cahce-registry" option is set and the image exists in the cache, it wi buildAndPushCmd.Flags().StringVar(&obj.flags.TargetArch, "target-arch", runtime.GOARCH, "Target architecture") buildAndPushCmd.Flags().StringVar(&obj.flags.IgnoreFile, "ignore-file", ".gitignore", "Name of the file with files to exclude (in the format of .gitignore)") buildAndPushCmd.Flags().StringVar(&obj.flags.CacheIncludeFile, "cache-include-file", ".cache-include", "Name of the file inside the app folder with additional files to include in checksumming (in the format of .gitignore)") + buildAndPushCmd.Flags().StringVar(&obj.flags.WindowsVersion, "windows-version", "", "Windows version to use for Windows containers") // Register the commands cmd.AddCommand(buildCmd) @@ -244,8 +247,13 @@ func (c *cmdE2EPerf) getCachedImage() (string, error) { return "", err } - // If cache is enable, try pulling from cache first - cachedImage := fmt.Sprintf("%s/%s-%s:%s-%s-%s", c.flags.CacheRegistry, c.cmdType, c.flags.Name, c.flags.TargetOS, c.flags.TargetArch, hashDir) + tag := fmt.Sprintf("%s-%s-%s", c.flags.TargetOS, c.flags.TargetArch, hashDir) + + if c.flags.WindowsVersion != "" { + tag = fmt.Sprintf("%s-%s-%s-%s", c.flags.TargetOS, c.flags.WindowsVersion, c.flags.TargetArch, hashDir) + } + + cachedImage := fmt.Sprintf("%s/%s-%s:%s", c.flags.CacheRegistry, c.cmdType, c.flags.Name, tag) return cachedImage, nil } @@ -325,6 +333,9 @@ func (c *cmdE2EPerf) buildDockerImage(cachedImage string) error { default: args = append(args, "--platform", c.flags.TargetOS+"/amd64") } + if c.flags.WindowsVersion != "" { + args = append(args, "--build-arg", "WINDOWS_VERSION="+c.flags.WindowsVersion) + } fmt.Printf("Running 'docker %s'\n", strings.Join(args, " ")) e := exec.Command("docker", args...) diff --git a/tests/apps/Dockerfile-windows b/tests/apps/Dockerfile-windows index 0486fc6280c..1a076a71c97 100644 --- a/tests/apps/Dockerfile-windows +++ b/tests/apps/Dockerfile-windows @@ -11,7 +11,7 @@ # limitations under the License. # -FROM mcr.microsoft.com/windows/nanoserver:1809 +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 WORKDIR /app COPY . . diff --git a/tests/apps/actordotnet/CarActor.csproj b/tests/apps/actordotnet/CarActor.csproj index df4886ce854..33428ece1ff 100644 --- a/tests/apps/actordotnet/CarActor.csproj +++ b/tests/apps/actordotnet/CarActor.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net6.0 diff --git a/tests/apps/actordotnet/Dockerfile b/tests/apps/actordotnet/Dockerfile index 34fb7899c3e..5e03ef1ab3c 100644 --- a/tests/apps/actordotnet/Dockerfile +++ b/tests/apps/actordotnet/Dockerfile @@ -1,8 +1,8 @@ -FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base +FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base WORKDIR /app EXPOSE 3000 -FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src COPY ["CarActor.csproj", "./"] RUN dotnet restore "CarActor.csproj" diff --git a/tests/apps/actordotnet/Dockerfile-windows b/tests/apps/actordotnet/Dockerfile-windows index 511eab928a8..70e2e2f6eb8 100644 --- a/tests/apps/actordotnet/Dockerfile-windows +++ b/tests/apps/actordotnet/Dockerfile-windows @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env WORKDIR /app # Copy csproj and restore as distinct layers @@ -10,7 +10,7 @@ COPY . ./ RUN dotnet publish -c Release -o out # Build runtime image -FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 +FROM mcr.microsoft.com/dotnet/aspnet:6.0 WORKDIR /app EXPOSE 3000 COPY --from=build-env /app/out . diff --git a/tests/apps/actorjava/Dockerfile-windows b/tests/apps/actorjava/Dockerfile-windows index 4df81cff22e..8efe1b3f530 100644 --- a/tests/apps/actorjava/Dockerfile-windows +++ b/tests/apps/actorjava/Dockerfile-windows @@ -1,3 +1,3 @@ -ARG WINDOWS_VERSION=1809 +ARG WINDOWS_VERSION=ltsc2022 # We are adding a Dockerfile because the building tools expect one, but we do not test this app on Windows FROM mcr.microsoft.com/windows/nanoserver:$WINDOWS_VERSION diff --git a/tests/apps/actorphp/Dockerfile-windows b/tests/apps/actorphp/Dockerfile-windows index 2e4550324f4..ad04abd95a2 100644 --- a/tests/apps/actorphp/Dockerfile-windows +++ b/tests/apps/actorphp/Dockerfile-windows @@ -1,4 +1,4 @@ -ARG WINDOWS_VERSION=1809 +ARG WINDOWS_VERSION=ltsc2022 FROM ghcr.io/dapr/windows-php-base:$WINDOWS_VERSION WORKDIR /inetpub diff --git a/tests/apps/actorpython/Dockerfile b/tests/apps/actorpython/Dockerfile index bd971620ce5..f1e586a8b34 100644 --- a/tests/apps/actorpython/Dockerfile +++ b/tests/apps/actorpython/Dockerfile @@ -11,7 +11,7 @@ # limitations under the License. # -FROM python:3.7-slim-buster +FROM python:3.9-slim-buster WORKDIR /app COPY . . diff --git a/tests/apps/actorpython/Dockerfile-windows b/tests/apps/actorpython/Dockerfile-windows index 46c96ad9275..50785bce8ff 100644 --- a/tests/apps/actorpython/Dockerfile-windows +++ b/tests/apps/actorpython/Dockerfile-windows @@ -1,4 +1,4 @@ -ARG WINDOWS_VERSION=1809 +ARG WINDOWS_VERSION=ltsc2022 FROM ghcr.io/dapr/windows-python-base:$WINDOWS_VERSION WORKDIR /app ADD . /app diff --git a/tests/apps/actorpython/requirements.txt b/tests/apps/actorpython/requirements.txt index 2bcb2a5d121..61bd2ef3d59 100644 --- a/tests/apps/actorpython/requirements.txt +++ b/tests/apps/actorpython/requirements.txt @@ -1 +1,2 @@ -flask-dapr>=1.0.0rc2 \ No newline at end of file +flask-dapr>=1.9.0 +typing-extensions \ No newline at end of file diff --git a/tests/dapr_tests.mk b/tests/dapr_tests.mk index a13665fc8f4..b3d0f7d12b9 100644 --- a/tests/dapr_tests.mk +++ b/tests/dapr_tests.mk @@ -115,6 +115,10 @@ $(error cannot find get minikube node ip address. ensure that you have minikube endif endif +ifeq ($(WINDOWS_VERSION),) +WINDOWS_VERSION=ltsc2022 +endif + # check the required environment variables check-e2e-env: ifeq ($(DAPR_TEST_REGISTRY),) @@ -169,7 +173,8 @@ build-push-e2e-app-$(1): check-e2e-env check-e2e-cache --dockerfile "$(DOCKERFILE)" \ --target-os "$(TARGET_OS)" \ --target-arch "$(TARGET_ARCH)" \ - --cache-registry "$(DAPR_CACHE_REGISTRY)" + --cache-registry "$(DAPR_CACHE_REGISTRY)" \ + --windows-version "$(WINDOWS_VERSION)" endef # Generate test app image build-push targets