diff --git a/.github/workflows/pr_ci.yml b/.github/workflows/pr_ci.yml index e41ff5cdb54..7dcde8681af 100644 --- a/.github/workflows/pr_ci.yml +++ b/.github/workflows/pr_ci.yml @@ -44,4 +44,3 @@ jobs: path: | test/OrchardCore.Tests.Functional/cms-tests/cypress/screenshots src/OrchardCore.Cms.Web/App_Data/logs - diff --git a/.github/workflows/preview_ci.yml b/.github/workflows/preview_ci.yml index e991162ad78..ae20d190767 100644 --- a/.github/workflows/preview_ci.yml +++ b/.github/workflows/preview_ci.yml @@ -53,6 +53,9 @@ jobs: run: | dotnet pack -c Release --no-build dotnet nuget push './src/**/*.nupkg' -t 600 -k ${{secrets.CLOUDSMITH_API_KEY}} -n -s https://nuget.cloudsmith.io/orchardcore/preview/v3/index.json --skip-duplicate + - name: Set up Docker Buildx + if: matrix.os == 'ubuntu-latest' + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub if: matrix.os == 'ubuntu-latest' uses: docker/login-action@v1 @@ -67,15 +70,11 @@ jobs: Get-ChildItem ./src/OrchardCore.Cms.Web/App_Data_Tests -Recurse | Remove-Item -Recurse -Confirm:$false $output = [System.IO.Path]::GetFullPath("./.build/release") dotnet publish -c Release --property:PublishDir=$output --no-build --framework net8.0 - docker build -f Dockerfile-linux-CI -t orchardproject/orchardcore-cms-linux:dev . + docker buildx build -f Dockerfile-CI --platform=linux/amd64 -t orchardproject/orchardcore-cms-linux:dev . docker push orchardproject/orchardcore-cms-linux:dev - name: Deploy preview docker image for windows - if: matrix.os == 'windows-latest' + shell: pwsh + if: matrix.os == 'ubuntu-latest' run: | - Get-ChildItem ./src/OrchardCore.Cms.Web/App_Data -Recurse | Remove-Item -Recurse -Confirm:$false - Get-ChildItem ./src/OrchardCore.Cms.Web/App_Data_Tests -Recurse | Remove-Item -Recurse -Confirm:$false - $output = [System.IO.Path]::GetFullPath("./.build/release") - dotnet publish -c Release --property:PublishDir=$output --no-build --framework net8.0 - docker build -f Dockerfile-windows-CI -t orchardproject/orchardcore-cms-windows:dev . - echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u="${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin + docker buildx build -f Dockerfile-CI --platform=windows/amd64 -t orchardproject/orchardcore-cms-windows:dev . docker push orchardproject/orchardcore-cms-windows:dev diff --git a/.github/workflows/release_ci.yml b/.github/workflows/release_ci.yml index 5848d6b0bdf..24074a6d2c3 100644 --- a/.github/workflows/release_ci.yml +++ b/.github/workflows/release_ci.yml @@ -64,6 +64,9 @@ jobs: run: | dotnet pack -c Release --no-build -p:Version=${{ steps.get_version.outputs.VERSION }} -p:TreatWarningsAsErrors=false dotnet nuget push './src/**/*.nupkg' -t 600 -k ${{secrets.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate + - name: Set up Docker Buildx + if: matrix.os == 'ubuntu-latest' + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub if: matrix.os == 'ubuntu-latest' uses: docker/login-action@v1 @@ -78,17 +81,13 @@ jobs: Get-ChildItem ./src/OrchardCore.Cms.Web/App_Data_Tests -Recurse | Remove-Item -Recurse -Confirm:$false $output = [System.IO.Path]::GetFullPath("./.build/release") dotnet publish -c Release --property:PublishDir=$output --no-build --framework net8.0 - docker build -f Dockerfile-linux-CI -t orchardproject/orchardcore-cms-linux:latest -t orchardproject/orchardcore-cms-linux:${{ steps.get_version.outputs.VERSION }} . + docker buildx build -f Dockerfile-CI --platform=linux/amd64 -t orchardproject/orchardcore-cms-linux:latest -t orchardproject/orchardcore-cms-linux:${{ steps.get_version.outputs.VERSION }} . docker push orchardproject/orchardcore-cms-linux:latest docker push "orchardproject/orchardcore-cms-linux:${{ steps.get_version.outputs.VERSION }}" - - name: Deploy preview docker image for windows - if: matrix.os == 'windows-latest' + - name: Deploy release docker image for windows + shell: pwsh + if: matrix.os == 'ubuntu-latest' run: | - Get-ChildItem ./src/OrchardCore.Cms.Web/App_Data -Recurse | Remove-Item -Recurse -Confirm:$false - Get-ChildItem ./src/OrchardCore.Cms.Web/App_Data_Tests -Recurse | Remove-Item -Recurse -Confirm:$false - $output = [System.IO.Path]::GetFullPath("./.build/release") - dotnet publish -c Release --property:PublishDir=$output --no-build --framework net8.0 - docker build -f Dockerfile-windows-CI -t orchardproject/orchardcore-cms-windows:latest -t orchardproject/orchardcore-cms-windows:${{ steps.get_version.outputs.VERSION }} . - echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u="${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin + docker buildx build -f Dockerfile-CI --platform=windows/amd64 -t orchardproject/orchardcore-cms-windows:latest -t orchardproject/orchardcore-cms-windows:${{ steps.get_version.outputs.VERSION }} . docker push orchardproject/orchardcore-cms-windows:latest docker push "orchardproject/orchardcore-cms-windows:${{ steps.get_version.outputs.VERSION }}" diff --git a/Dockerfile b/Dockerfile index 0c1f69e2ce3..85b899d1c23 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,6 @@ +FROM --platform=$BUILDPLATFORM golang:alpine AS build +ARG TARGETOS + FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env LABEL stage=build-env WORKDIR /app @@ -7,7 +10,10 @@ COPY ./src /app RUN dotnet publish /app/OrchardCore.Cms.Web -c Release -o ./build/release --framework net8.0 # Build runtime image -FROM mcr.microsoft.com/dotnet/aspnet:8.0 +FROM mcr.microsoft.com/dotnet/aspnet:8.0-nanoserver-1809 AS build_windows +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS build_linux +FROM build_${TARGETOS} AS aspnet + EXPOSE 80 ENV ASPNETCORE_URLS http://+:80 WORKDIR /app diff --git a/Dockerfile-linux-CI b/Dockerfile-CI similarity index 51% rename from Dockerfile-linux-CI rename to Dockerfile-CI index 1a019b53864..f118690e976 100644 --- a/Dockerfile-linux-CI +++ b/Dockerfile-CI @@ -1,7 +1,11 @@ # This Docker file is intended for the CI # A prerequisite is a published application in the .build/release +FROM --platform=$BUILDPLATFORM golang:alpine AS build +ARG TARGETOS -FROM mcr.microsoft.com/dotnet/aspnet:8.0 +FROM mcr.microsoft.com/dotnet/aspnet:8.0-nanoserver-1809 AS build_windows +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS build_linux +FROM build_${TARGETOS} AS aspnet EXPOSE 80 ENV ASPNETCORE_URLS http://+:80 diff --git a/Dockerfile-windows-CI b/Dockerfile-windows-CI deleted file mode 100644 index 4db8aab657d..00000000000 --- a/Dockerfile-windows-CI +++ /dev/null @@ -1,10 +0,0 @@ -# This Docker file is intended for the CI -# A prerequisite is a published application in the .build/release - -FROM mcr.microsoft.com/dotnet/aspnet:8.0-nanoserver-1809 - -EXPOSE 80 -ENV ASPNETCORE_URLS http://+:80 -WORKDIR /app -COPY .build/release /app -ENTRYPOINT ["dotnet", "OrchardCore.Cms.Web.dll"]