Skip to content

Commit

Permalink
Testing docker build (#14825)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtkech authored Dec 4, 2023
1 parent 1c9e8be commit ed99129
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/preview_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ 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-CI --platform=linux/amd64 -t orchardproject/orchardcore-cms-linux:dev .
docker build -f Dockerfile-linux-CI -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'
Expand All @@ -76,6 +76,6 @@ 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-CI --platform=windows/amd64 -t orchardproject/orchardcore-cms-windows:dev .
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 push orchardproject/orchardcore-cms-windows:dev
4 changes: 2 additions & 2 deletions .github/workflows/release_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ 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-CI --platform=linux/amd64 -t orchardproject/orchardcore-cms-linux:latest -t orchardproject/orchardcore-cms-linux:${{ steps.get_version.outputs.VERSION }} .
docker build -f Dockerfile-linux-CI -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
Expand All @@ -88,7 +88,7 @@ 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-CI --platform=windows/amd64 -t orchardproject/orchardcore-cms-windows:latest -t orchardproject/orchardcore-cms-windows:${{ steps.get_version.outputs.VERSION }} .
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 push orchardproject/orchardcore-cms-windows:latest
docker push "orchardproject/orchardcore-cms-windows:${{ steps.get_version.outputs.VERSION }}"
8 changes: 1 addition & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
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
Expand All @@ -10,10 +7,7 @@ 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-nanoserver-1809 AS build_windows
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS build_linux
FROM build_${TARGETOS} AS aspnet

FROM mcr.microsoft.com/dotnet/aspnet:8.0
EXPOSE 80
ENV ASPNETCORE_URLS http://+:80
WORKDIR /app
Expand Down
6 changes: 1 addition & 5 deletions Dockerfile-CI → Dockerfile-linux-CI
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# 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-nanoserver-1809 AS build_windows
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS build_linux
FROM build_${TARGETOS} AS aspnet
FROM mcr.microsoft.com/dotnet/aspnet:8.0

EXPOSE 80
ENV ASPNETCORE_URLS http://+:80
Expand Down
10 changes: 10 additions & 0 deletions Dockerfile-windows-CI
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 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"]

3 comments on commit ed99129

@MikeAlhayek
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jtkech we could have done a simpler approach by providing the image name as a parameter and kept a single file. However, take a look at the comment from @sebastienros about general purpose docker #14707 (comment)

@jtkech
Copy link
Member Author

@jtkech jtkech commented on ed99129 Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, just wanted to check that the issue was only related to the referenced image.

Also thinking that's a temporary issue.

@jtkech
Copy link
Member Author

@jtkech jtkech commented on ed99129 Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, being able to use TARGETPLATFORM and BUILDPLATFORM would be good, looks like we would need to use the buildx command but maybe the docker build command already uses buildx by default, or not depending on the docker version we are using.

In order to build multi-platform container images, we will use the docker buildxcommand. Buildx is a Docker component that enables many powerful build features with a familiar Docker user experience. All builds executed via buildx run with Moby Buildkit builder engine. Buildx can also be used standalone or, for example, to run builds in a Kubernetes cluster. In the next version of Docker CLI, the docker build command will also start to use Buildx by default.

When I will have time I will do a testing PR with a custom github action to check if these dynamic properties can be used.

Please sign in to comment.