OrchardCMS / Orchard

Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform.
https://orchardproject.net
BSD 3-Clause "New" or "Revised" License
2.37k stars 1.12k forks source link

Dockerise #8735

Closed dewijones92 closed 3 months ago

dewijones92 commented 8 months ago

Hello :) I was wondering if you could help me dockerise Orchard I thought it was best to branch off OrchardCMS:1.10.x - as dev seems a little dead

I am having trouble building the container. I think it is a problem with the base image I am using.

From the repo CI build logs here it seems this is the image it's using. At the bottom of this page it states the corresponding/matching docker image: image

Despite using what seems to be the correct image - I am facing issues:

       "C:\src\Orchard.proj" (Compile target) (1) ->
       "C:\src\src\Orchard.sln" (Build target) (2) ->
       "C:\src\src\Orchard.Web\Orchard.Web.csproj.metaproj" (default target) (3) ->
       "C:\src\src\Tools\MSBuild.Orchard.Tasks\MSBuild.Orchard.Tasks.csproj" (default target) (19) ->
         C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\Microsoft.CSharp.CurrentVersion.targets(129,9): error MSB3884: Could not find rule set file "AllRules.ruleset". [C:\src\src\Tools\MSBuild.Orchard.Tasks\MSBuild.Orchard.Tasks.csproj]

       "C:\src\Orchard.proj" (Compile target) (1) ->
       "C:\src\src\Orchard.sln" (Build target) (2) ->
       "C:\src\src\Orchard.Web\Orchard.Web.csproj.metaproj" (default target) (3) ->
       "C:\src\src\Orchard.Web\Modules\Orchard.Caching\Orchard.Caching.csproj" (default target) (64) ->
         C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\Microsoft.CSharp.CurrentVersion.targets(129,9): error MSB3884: Could not find rule set file "AllRules.ruleset". [C:\src\src\Orchard.Web\Modules\Orchard.Caching\Orchard.Caching.csproj]

       "C:\src\Orchard.proj" (Compile target) (1) ->
       "C:\src\src\Orchard.sln" (Build target) (2) ->
       "C:\src\src\Orchard.Web\Orchard.Web.csproj.metaproj" (default target) (3) ->
       "C:\src\src\Orchard.Tests.Modules\Orchard.Tests.Modules.csproj" (default target) (28) ->
       "C:\src\src\Orchard.Tests\Orchard.Framework.Tests.csproj" (default target) (29:2) ->
       "C:\src\src\Orchard.Web\Core\Orchard.Core.csproj" (default target) (6:15) ->
         C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\Microsoft.CSharp.CurrentVersion.targets(129,9): error MSB3884: Could not find rule set file "AllRules.ruleset". [C:\src\src\Orchard.Web\Core\Orchard.Core.csproj]

       "C:\src\Orchard.proj" (Compile target) (1) ->
       "C:\src\src\Orchard.sln" (Build target) (2) ->
       "C:\src\src\Orchard.Web\Orchard.Web.csproj.metaproj" (default target) (3) ->
       "C:\src\src\Orchard.Web\Modules\Orchard.MultiTenancy\Orchard.MultiTenancy.csproj" (default target) (23) ->
         C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\Microsoft.CSharp.CurrentVersion.targets(129,9): error MSB3884: Could not find rule set file "AllRules.ruleset". [C:\src\src\Orchard.Web\Modules\Orchard.MultiTenancy\Orchard.MultiTenancy.csproj]

       "C:\src\Orchard.proj" (Compile target) (1) ->
       "C:\src\src\Orchard.sln" (Build target) (2) ->
       "C:\src\src\Orchard.Web\Orchard.Web.csproj.metaproj" (default target) (3) ->
       "C:\src\src\Orchard.Tests.Modules\Orchard.Tests.Modules.csproj" (default target) (28) ->
       "C:\src\src\Orchard.Web\Modules\Orchard.ImportExport\Orchard.ImportExport.csproj" (default target) (36:2) ->
       "C:\src\src\Orchard.Web\Modules\Orchard.Recipes\Orchard.Recipes.csproj" (default target) (39:3) ->
       "C:\src\src\Orchard.Web\Modules\Orchard.Packaging\Orchard.Packaging.csproj" (default target) (22:4) ->
       "C:\src\src\Orchard.Web\Modules\Orchard.Modules\Orchard.Modules.csproj" (default target) (38:3) ->
         C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\Microsoft.CSharp.CurrentVersion.targets(129,9): error MSB3884: Could not find rule set file "AllRules.ruleset". [C:\src\src\Orchard.Web\Modules\Orchard.Modules\Orchard.Modules.csproj]

       "C:\src\Orchard.proj" (Compile target) (1) ->
       "C:\src\src\Orchard.sln" (Build target) (2) ->
       "C:\src\src\Orchard.Web\Orchard.Web.csproj.metaproj" (default target) (3) ->
       "C:\src\src\Orchard.Web\Modules\TinyMce\TinyMce.csproj" (default target) (71) ->
         C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\Microsoft.CSharp.CurrentVersion.targets(129,9): error MSB3884: Could not find rule set file "AllRules.ruleset". [C:\src\src\Orchard.Web\Modules\TinyMce\TinyMce.csproj]

       "C:\src\Orchard.proj" (Compile target) (1) ->
       "C:\src\src\Orchard.sln" (Build target) (2) ->
       "C:\src\src\Orchard.Web\Orchard.Web.csproj.metaproj" (default target) (3) ->
       "C:\src\src\Orchard.Profile\Orchard.Profile.csproj" (default target) (73) ->
         C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\Microsoft.CSharp.CurrentVersion.targets(129,9): error MSB3884: Could not find rule set file "AllRules.ruleset". [C:\src\src\Orchard.Profile\Orchard.Profile.csproj]

    0 Warning(s)
    9 Error(s)

Time Elapsed 00:00:06.61
The command 'powershell -Command msbuild Orchard.proj /m /t:Compile /p:MvcBuildViews=true /p:TreatWarningsAsErrors=true -WarnAsError' returned a non-zero code: 1
PS C:\Users\DewiJ\source\repos\Orchard>

The CI build logs do not output such an error.

What can you see wrong with my docker config? What do I need to change to build successfully like the CI logs? thanks

dewijones92 commented 8 months ago

this is the command to build the image: (I increased the memory allocated to circumvent out of memory errors) docker.exe build -m 20GB -t 15_test .

MatteoPiovanelli-Laser commented 8 months ago

I haven't tried to containerize Orchard, so my contribution here may not be helpful, but I'll try, because trying for this has been on my wishlist for a while:

I haven't seen those errors you are showing specifically yet. The projects in the log point to different rulesets (at least those I sampled), rather than the one in the error log. Could be an issue with some default configuration of msbuild?

A while ago I had to script a system to build Orchard. It checks for the location of the most recent msbuild and then builds Orchard in release mode, publishing everything including compiled views to a separate folder. Note that we have a custom solution that include Orchard and a bunch of other stuff, so YMMV, but hopefully this can help get you unstuck. The gist of it is (stripped of some stuff that's custom to our solutions, so it may not work as is):

# finding the path of the latest VS msbuild.exe
$msbuildfullpath =&"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe
# build everything once to have the dlls
&$msbuildfullpath /m /nologo /v:q '.\path\to\orchard.sln' /t:Rebuild /p:Configuration="Release" /p:Platform="Any CPU" /noWarn:"CS1591;CS1570;CS1572;CS1573"
# copy all dlls from the bin folders of modules and themes to the solution's, because that made building shapes easier
Set-Location '.\path\to\Orchard\src\Orchard.Web'
Get-ChildItem -Path ".\Modules", ".\Themes" -Directory | ForEach-Object {
    # If there is a bin folder (some themes don't have it)
    if (Test-Path ($_.FullName + '\bin')) {
        # Copy files from this module to the bin, without replacing
        Copy-Item -Path ($_.FullName + '\bin\*.dll') -Exclude (Get-ChildItem '.\bin') -Destination '.\bin'
    }
}
# publish
&$msbuildfullpath Orchard\src\Orchard.Web\Orchard.Web.csproj /p:PublishProfile=$pubProfile /p:DeployRelease=true -verbosity:minimal -maxcpucount

An example build profile we've been using:

<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
  <PropertyGroup>
    <DeleteExistingFiles>true</DeleteExistingFiles>
    <ExcludeApp_Data>false</ExcludeApp_Data>
    <LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <PublishProvider>FileSystem</PublishProvider>
    <PublishUrl>..\..\..\..\PublishOutput\Orchard.Web</PublishUrl>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <_TargetId>Folder</_TargetId>
    <SiteUrlToLaunchAfterPublish />
    <PrecompileBeforePublish>true</PrecompileBeforePublish>
    <EnableUpdateable>false</EnableUpdateable>
    <DebugSymbols>false</DebugSymbols>
    <WDPMergeOption>DonotMerge</WDPMergeOption>
  </PropertyGroup>
</Project>
dewijones92 commented 8 months ago

@MatteoPiovanelli-Laser Hello please see my updated commits (for some reason - I can not update this PR - so please see this diff) https://github.com/OrchardCMS/Orchard/compare/1.10.x...dewijones92:Orchard:dewijones92/dockerise

I can now build it successfully within the container

The problem is related to this bit image

the container is giving me a runtime error image

I see no relevant logs in the container C:\inetpub\logs\LogFiles\W3SVC1

As you can see from the diff https://github.com/OrchardCMS/Orchard/compare/1.10.x...dewijones92:Orchard:dewijones92/dockerise - I have switched off customer errors.

Any tips to see what is wrong? @MatteoPiovanelli-Laser thanks

BenedekFarkas commented 4 months ago

Is this something you'd really like to merge or just an experiment? What are the use-cases here?

MatteoPiovanelli-Laser commented 4 months ago

Benedek makes fair questions. Besides that, are you sure about the paths in the docker file? I'd check the folder structure inside your container. The other thing, I'd make sure the application pool within the container itself has all required permissions to work on the folders for the application. Also I don't see where, in your dockerfile, you are setting up IIS to run Orchard. May be you don't need to do that: I'm not familiar with creating containers for this.

BenedekFarkas commented 3 months ago

I'll close this PR, because it's not something we'd merge in now, but please let us know if you make any progress (you can still comment here or head over to Discord: https://discord.com/channels/551136772243980291/551137194689953848).