microsoft / navcontainerhelper

Official Microsoft repository for BcContainerHelper, a PowerShell module, which makes it easier to work with Business Central Containers on Docker.
MIT License
384 stars 247 forks source link

Run\start.ps1 fails when running Local-DevEnv.ps1 (CICD Workshop HelloWorld.AppSource) #2207

Closed achim-t closed 2 years ago

achim-t commented 2 years ago

Describe the issue Following along with the CICD Workshop for HelloWorld.AppSource there is an error in the creation of the docker image when setting up the local development environment.

The only setting I changed is "vaultNameForLocal".

Scripts used to create container and cause the issue

.\Local-DevEnv.ps1

Full output of scripts

Set artifact = //18.2.26217.26754/us
Set pipelineName = HelloWorld.AppSource-ci                                                                              
Set containerName = helloworld-appsource-ci                                                                             
Set installApps = ''                                                                                                    
Set previousApps = 'https://businesscentralapps.azureedge.net/helloworld-appsource/latest/apps.zip'                     
Set appSourceCopMandatoryAffixes = 'hw_'                                                                               
Set appSourceCopSupportedCountries = 'us,dk,gb'                                                                        
Set appFolders = 'app,base'
Set testFolders = 'test'
Set memoryLimit = '6G'
Set additionalCountries = ''
Set genericImageName = ''
Set vaultNameForLocal = 'xxx'
Set bcContainerHelperVersion = 'dev'
Set installTestRunner = True
Set installTestFramework = False
Set installTestLibraries = False
Set installPerformanceToolkit = False
Set enableCodeCop = False
Set enableAppSourceCop = True
Set enablePerTenantExtensionCop = False
Set enableUICop = True
Set useDefaultAppSourceRuleSet = False
Set doNotSignApps = True
Set doNotRunTests = False
Set cacheImage = True
Set CreateRuntimePackages = True
Downloading https://github.com/microsoft/navcontainerhelper/archive/dev.zip
BcContainerHelper version 2.0.21-dev
WARNING: Upcoming breaking changes in the cmdlet 'Get-AzKeyVault' :
This cmdlet will use Microsoft Graph in Az 7.x and later.
Visit https://go.microsoft.com/fwlink/?linkid=2174792 for migration guide and breaking changes.
Note : Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other
information on breaking changes in Azure PowerShell.
Get Secret bcInsiderPasswordSecret
Get Secret bcInsiderUsernameSecret
Get Secret CodeSignCertPfxFileSecret
Get Secret codeSignCertPfxPasswordSecret
Get Secret CodeSignPfxFileSecret
Get Secret CodeSignPfxPasswordSecret
Get Secret InsiderSasTokenSecret
Get Secret licenseFileSecret
Get Secret PasswordSecret
Get Secret StorageConnectionStringSecret
Get Secret UsernameSecret
Determining artifacts to use
  _____                               _
 |  __ \                             | |
 | |__) |_ _ _ __ __ _ _ __ ___   ___| |_ ___ _ __ ___
 |  ___/ _` | '__/ _` | '_ ` _ \ / _ \ __/ _ \ '__/ __|
 | |  | (_| | | | (_| | | | | | |  __/ |_  __/ |  \__ \
 |_|   \__,_|_|  \__,_|_| |_| |_|\___|\__\___|_|  |___/

Pipeline name               HelloWorld.AppSource-ci
Container name              helloworld-appsource-ci
Image name                  bcimage
ArtifactUrl                 https://bcartifacts.azureedge.net/sandbox/18.2.26217.26754/us
SasToken                    Not Specified
BcAuthContext               Not Specified
Environment
ReUseContainer              False
KeepContainer               True
Auth                        UserPassword
Credential                  Specified
CompanyName
MemoryLimit                 6G
Enable Task Scheduler       False
Assign Premium Plan         False
Install Test Runner         True
Install Test Framework      False
Install Test Libraries      False
Install Perf. Toolkit       False
CopySymbolsFromContainer    False
enableCodeCop               False
enableAppSourceCop          False
enableUICop                 False
enablePerTenantExtensionCop False
doNotPerformUpgrade         False
uninstallRemovedApps        False
escapeFromCops              False
doNotBuildTests             False
doNotRunTests               True
doNotRunBcptTests           False
useDefaultAppSourceRuleSet  False
rulesetFile
azureDevOps                 False
gitLab                      False
gitHubActions               False
License file                Specified
CodeSignCertPfxFile         Not specified
CodeSignCertPfxPassword     Not specified
CodeSignCertIsSelfSigned    False
KeyVaultCertPfxFile         Not specified
KeyVaultCertPfxPassword     Not specified
KeyVaultClientId
TestResultsFile             C:\Users\Achim\Documents\AL\HelloWorld.AppSource\TestResults.xml
BcptTestResultsFile         C:\Users\Achim\Documents\AL\HelloWorld.AppSource\bcptTestResults.json
TestResultsFormat           JUnit
AdditionalCountries
PackagesFolder
OutputFolder
BuildArtifactFolder
CreateRuntimePackages       False
AppVersion
AppBuild                    0
AppRevision                 0
Install Apps
- None
Install Test Apps
- None
Previous Apps
- None
Application folders
- C:\Users\Achim\Documents\AL\HelloWorld.AppSource\app
- C:\Users\Achim\Documents\AL\HelloWorld.AppSource\base
Test application folders
- C:\Users\Achim\Documents\AL\HelloWorld.AppSource\test
BCPT Test application folders
- None
Custom CodeCops
- None

  _____       _ _ _                                          _        _
 |  __ \     | | (_)                                        (_)      (_)
 | |__) |   _| | |_ _ __   __ _    __ _  ___ _ __   ___ _ __ _  ___   _ _ __ ___   __ _  __ _  ___
 |  ___/ | | | | | | '_ \ / _` |  / _` |/ _ \ '_ \ / _ \ '__| |/ __| | | '_ ` _ \ / _` |/ _` |/ _ \
 | |   | |_| | | | | | | | (_| | | (_| |  __/ | | |  __/ |  | | (__  | | | | | | | (_| | (_| |  __/
 |_|    \__,_|_|_|_|_| |_|\__, |  \__, |\___|_| |_|\___|_|  |_|\___| |_|_| |_| |_|\__,_|\__, |\___|
                           __/ |   __/ |                                                 __/ |
                          |___/   |___/                                                 |___/

INFO: Windows 10 21H1/21H2 images are not yet available, using 2004 as these are found to work better than 20H2 on 21H1/21H2
Pulling mcr.microsoft.com/businesscentral:10.0.19041.1348

Pulling generic image took 4 seconds

   _____                _   _                               _        _
  / ____|              | | (_)                             | |      (_)
 | |     _ __ ___  __ _| |_ _ _ __   __ _    ___ ___  _ __ | |_ __ _ _ _ __   ___ _ __
 | |    | '__/ _ \/ _` | __| | '_ \ / _` |  / __/ _ \| '_ \| __/ _` | | '_ \ / _ \ '__|
 | |____| | |  __/ (_| | |_| | | | | (_| | | (__ (_) | | | | |_ (_| | | | | |  __/ |
  \_____|_|  \___|\__,_|\__|_|_| |_|\__, |  \___\___/|_| |_|\__\__,_|_|_| |_|\___|_|
                                     __/ |
                                    |___/

WARNING: Container name should not exceed 15 characters
BcContainerHelper is version 2.0.21-dev
BcContainerHelper is running as administrator
Host is Microsoft Windows 10 Pro - 21H1
Docker Client Version is 20.10.10
Docker Server Version is 20.10.10
Fetching all docker images
Fetching all docker volumes
ArtifactUrl and ImageName specified
Building multitenant image bcimage:sandbox-18.2.26217.26754-us-mt based on mcr.microsoft.com/businesscentral:10.0.19041.1348 with https://bcartifacts.azureedge.net/sandbox/18.2.26217.26754/us
Generic Tag: 1.0.1.8
Container OS Version: 10.0.19041.1348 (2004)
Host OS Version: 10.0.19043.1348 (21H1)
WARNING: Host OS is 21H1 and Container OS is 2004, defaulting to process isolation. If you experience problems, add -isolation hyperv.
Using process isolation
Using license file [url removed]
Downloading c:\bcartifacts.cache\of4vve3l.ltv\my\license.flf
Files in c:\bcartifacts.cache\of4vve3l.ltv\my:
- license.flf
Copying Platform Artifacts
c:\bcartifacts.cache\sandbox\18.2.26217.26754\platform
Copying Database
Copying Licensefile
Copying ConfigurationPackages
C:\bcartifacts.cache\sandbox\18.2.26217.26754\us\ConfigurationPackages
Copying Extensions
C:\bcartifacts.cache\sandbox\18.2.26217.26754\us\Extensions
Copying Applications.US
C:\bcartifacts.cache\sandbox\18.2.26217.26754\us\Applications.US
c:\bcartifacts.cache\of4vve3l.ltv
Sending build context to Docker daemon  2.023GB

Step 1/6 : FROM mcr.microsoft.com/businesscentral:10.0.19041.1348
 ---> 26dc4b934ad8
Step 2/6 : ENV DatabaseServer=localhost DatabaseInstance=SQLEXPRESS DatabaseName=CRONUS IsBcSandbox=Y artifactUrl=https://bcartifacts.azureedge.net/sandbox/18.2.26217.26754/us filesOnly=False
 ---> Using cache
 ---> 11d65c79ecee
Step 3/6 : COPY my /run/
 ---> ca82042b4726
Step 4/6 : COPY NAVDVD /NAVDVD/
 ---> 67b390f1df86
 ---> Running in 85aa2b07b8bb
Using installer from C:\Run\150-new
Installing Business Central
Installing from DVD
Starting Local SQL Server
Starting Internet Information Server
Copying Service Tier Files
C:\NAVDVD\ServiceTier\Program Files
C:\NAVDVD\ServiceTier\System64Folder
Copying PowerShell Scripts
C:\NAVDVD\WindowsPowerShellScripts\Cloud\NAVAdministration
C:\NAVDVD\WindowsPowerShellScripts\WebSearch
Copying dependencies
Copying ReportBuilder
Importing PowerShell Modules
Determining Database Collation
Restoring CRONUS Demo Database
The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; \Run\start.ps1 -installOnly -multitenant' returned a non-zero code: 3221226505
Docker Build failed with exit code -1073740791
At C:\Users\Achim\AppData\Local\Temp\6b8c1552-800b-4400-b211-f5bda5c6764b\ContainerHandling\New-NavImage.ps1:635
char:25
+ ...              throw "Docker Build failed with exit code $LastExitCode"
+                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Docker Build fa...ode -1073740791:String) [], RuntimeException
    + FullyQualifiedErrorId : Docker Build failed with exit code -1073740791

Docker Desktop 4.2.0 (70708)

freddydk commented 2 years ago

This is likely the problems we have with Windows 10 - there are several of these. You can try with hyperv isolation and see if that solves the issue.

achim-t commented 2 years ago

Since RunAlPipeline doesn't have a parameter for isolation, I would have to override the NewBcContainer scriptblock, right?

achim-t commented 2 years ago

I created a scriptblock:

$NewBcContainer = { 
    Param([Hashtable]$parameters) 
    $parameters.isolation = "hyperv"

    New-BcContainer @parameters
    Invoke-ScriptInBcContainer $parameters.ContainerName -scriptblock { $progressPreference = 'SilentlyContinue' } 
}

And added another parameter to the Run-AlPipeline call:

    -NewBcContainer $NewBcContainer `

With hyperv isolation it did indeed work.