Skip to content

Commit

Permalink
Merge pull request #7 from NAVRockClimber/dev
Browse files Browse the repository at this point in the history
Make it version 0.1
  • Loading branch information
NAVRockClimber authored Jul 21, 2020
2 parents ced863d + ea8ed69 commit 252d062
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vscode
49 changes: 49 additions & 0 deletions Dockerfile.core
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# escape=`
ARG BASE
FROM mcr.microsoft.com/windows/servercore:$BASE as mother
ARG NCHVERSION
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]

RUN Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force; `
Install-Module navcontainerhelper -MinimumVersion $env:NCHVERSION -MaximumVersion $env:NCHVERSION -Force;

ARG TYPE
ARG COUNTRY
ARG VERSION

RUN Import-Module navcontainerhelper; `
Download-Artifacts -artifactUrl (Get-BCArtifactUrl -type $env:TYPE -country $env:COUNTRY -version $env:VERSION) -includePlatform;

RUN New-Item -Path c:\artifacts -ItemType Directory; `
New-Item -Path c:\bin -ItemType Directory; `
Start-Process "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\Prerequisite` Components\Open` XML` SDK` 2.5` for` Microsoft` Office\OpenXMLSDKv25.msi" "/qn" -PassThru | Wait-Process; `
Copy-Item "C:\Program` Files` `(x86`)\Open` XML` SDK\V2.5\lib" "C:\assemblies\OpenXMLSdk" -Recurse; `
Copy-Item "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\ModernDev\program` files\Microsoft` Dynamics` NAV\*\AL` Development` Environment\ALLanguage.vsix" "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\ALLanguage.zip"; `
Copy-Item "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\ModernDev\program` files\Microsoft` Dynamics` NAV\*\AL` Development` Environment\System.app" "C:\artifacts\System.app"; `
Get-ChildItem -Path "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\$env:COUNTRY" -Filter *.app -Recurse | % { Copy-Item $_.FullName "C:/artifacts/" }; `
Expand-Archive "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\ALLanguage.zip" "C:\alc"; `
Copy-Item "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\LegacyDlls\program` files\Microsoft` Dynamics` NAV\160\RoleTailored` Client" "C:\assemblies\RoleTailoredClient" -Recurse; `
Copy-Item "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\ServiceTier\program` files\Microsoft` Dynamics` NAV\160\Service" "C:\assemblies\Service" -Recurse; `
Copy-Item "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\Test` Assemblies\Mock` Assemblies" "C:\assemblies\MockAssemblies" -Recurse;

FROM mcr.microsoft.com/windows/servercore:$BASE
ARG TYPE
ARG COUNTRY
ARG VERSION
COPY --from=mother c:/alc/extension/bin c:/bin
COPY --from=mother C:/artifacts C:/symbols
COPY --from=mother C:/assemblies c:/assemblies
COPY Dummy.ruleset.json c:\dummy.ruleset.json

ENV rulesetfile='c:\dummy.ruleset.json'
CMD c:\bin\win32\alc.exe `
/project:c:\src `
/packagecachepath:c:\symbols `
/out:c:\src\app.app `
/errorlog:c:\src\alc.log `
/loglevel:Warning `
/ruleset:%rulesetfile% `
/analyzer:c:\bin\Analyzers\Microsoft.Dynamics.Nav.CodeCop.dll `
/analyzer:c:\bin\Analyzers\Microsoft.Dynamics.Nav.AppSourceCop.dll `
/analyzer:c:\bin\Analyzers\Microsoft.Dynamics.Nav.UICop.dll `
/assemblyprobingpaths:"c:\assemblies\OpenXMLSdk","C:\src\.netpackages","C:\assemblies\RoleTailoredClient","C:\assemblies\Service","C:\assemblies\MockAssemblies","c:\windows\assembly"
49 changes: 49 additions & 0 deletions Dockerfile.nano
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# escape=`
ARG BASE
FROM mcr.microsoft.com/windows/servercore:$BASE as mother
ARG NCHVERSION
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]

RUN Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force; `
Install-Module navcontainerhelper -MinimumVersion $env:NCHVERSION -MaximumVersion $env:NCHVERSION -Force;

ARG TYPE
ARG COUNTRY
ARG VERSION

RUN Import-Module navcontainerhelper; `
Download-Artifacts -artifactUrl (Get-BCArtifactUrl -type $env:TYPE -country $env:COUNTRY -version $env:VERSION) -includePlatform;

RUN New-Item -Path c:\artifacts -ItemType Directory; `
New-Item -Path c:\bin -ItemType Directory; `
Start-Process "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\Prerequisite` Components\Open` XML` SDK` 2.5` for` Microsoft` Office\OpenXMLSDKv25.msi" "/qn" -PassThru | Wait-Process; `
Copy-Item "C:\Program` Files` `(x86`)\Open` XML` SDK\V2.5\lib" "C:\assemblies\OpenXMLSdk" -Recurse; `
Copy-Item "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\ModernDev\program` files\Microsoft` Dynamics` NAV\*\AL` Development` Environment\ALLanguage.vsix" "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\ALLanguage.zip"; `
Copy-Item "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\ModernDev\program` files\Microsoft` Dynamics` NAV\*\AL` Development` Environment\System.app" "C:\artifacts\System.app"; `
Get-ChildItem -Path "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\$env:COUNTRY" -Filter *.app -Recurse | % { Copy-Item $_.FullName "C:/artifacts/" }; `
Expand-Archive "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\ALLanguage.zip" "C:\alc"; `
Copy-Item "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\LegacyDlls\program` files\Microsoft` Dynamics` NAV\160\RoleTailored` Client" "C:\assemblies\RoleTailoredClient" -Recurse; `
Copy-Item "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\ServiceTier\program` files\Microsoft` Dynamics` NAV\160\Service" "C:\assemblies\Service" -Recurse; `
Copy-Item "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\Test` Assemblies\Mock` Assemblies" "C:\assemblies\MockAssemblies" -Recurse;

FROM mcr.microsoft.com/windows/nanoserver:$BASE
ARG TYPE
ARG COUNTRY
ARG VERSION
COPY --from=mother c:/alc/extension/bin c:/bin
COPY --from=mother C:/artifacts C:/symbols
COPY --from=mother C:/assemblies c:/assemblies
COPY Dummy.ruleset.json c:\dummy.ruleset.json

ENV rulesetfile='c:\dummy.ruleset.json'
CMD c:\bin\win32\alc.exe `
/project:c:\src `
/packagecachepath:c:\symbols `
/out:c:\src\app.app `
/errorlog:c:\src\alc.log `
/loglevel:Error `
/ruleset:%rulesetfile% `
/analyzer:c:\bin\Analyzers\Microsoft.Dynamics.Nav.CodeCop.dll `
/analyzer:c:\bin\Analyzers\Microsoft.Dynamics.Nav.AppSourceCop.dll `
/analyzer:c:\bin\Analyzers\Microsoft.Dynamics.Nav.UICop.dll `
/assemblyprobingpaths:"c:\assemblies\OpenXMLSdk","C:\src\.netpackages","C:\assemblies\RoleTailoredClient","C:\assemblies\Service"
3 changes: 3 additions & 0 deletions Dummy.ruleset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "Cops ruleset"
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 NAVRockClimber

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
46 changes: 31 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
# Introduction
TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.
Dockerfiles for creating an ALC compiler image with all default dependencies from Microsoft. Special conisideration was to limit the number of environment variables to an absolute minimum. If additional parameters and / or dependencies are needed you should override the default docker CMD in your RUN command.

# Getting Started
TODO: Guide users through getting your code up and running on their own system. In this section you can talk about:
1. Installation process
2. Software dependencies
3. Latest releases
4. API references
# Build the image

# Build and Test
TODO: Describe and show how to build your code and run the tests.
For building the image you need to specify certain build arguments:

# Contribute
TODO: Explain how other users and developers can contribute to make your code better.
- BASE: The base tag for the release channel of your architecture e.g.: 1709, 1803, 1909
- NCHVERSION: The version of Freddy's navcontainerhelper. Only used in the intermediate image for pulling and extracting the artifacts.
- TYPE, COUNTRY, VERSION: These arguments are passed into Freddy Scripts. See the possible values in Freddy description of Get-BCArtifactUrl.

If you want to learn more about creating good readme files then refer the following [guidelines](https://docs.microsoft.com/en-us/azure/devops/repos/git/create-a-readme?view=azure-devops). You can also seek inspiration from the below readme files:
- [ASP.NET Core](https://github.com/aspnet/Home)
- [Visual Studio Code](https://github.com/Microsoft/vscode)
- [Chakra Core](https://github.com/Microsoft/ChakraCore)
The image itself is build by the following:`

```
docker build -t <imagename>:<tag> --build-arg BASE=<sac tag> --build-arg NCHVERSION=<Version> --build-arg TYPE=<OnPrem/Sandbox> --build-arg COUNTRY=<de> --build-arg VERSION=<16.2.13509.13779> -f .\Dockerfile.nano .
```

# Run the container

The most simple variant for running the compiler would be:
```
docker run -v <App Folder Host>:C:\src -v -e RulesetFile="c:\src\Cop.ruleset.json" --name alcnano --rm alc:<tag>
```

If the compile process takes a long time you can try to improve it with granting more memory to the container. This reduced the compile time of about 7000 AL files from over 30 minutes to 3 minutes.
```
docker run -v <App Folder Host>:C:\src -v -e RulesetFile="c:\src\Cop.ruleset.json" --memory 10G --name alcnano --rm alc:<tag>
```

# Choosing the right image

If you don't have any dotnet declarations you should be able to use the much smaller Nanoserver Image. Elsewise you got to choose the servercore image due to it contains the .Net framework.

# Converting the output for DevOps

For usage with DevOps you can use the [Convert-ALC-Output.ps1](https://raw.githubusercontent.com/NAVRockClimber/convert-alc-output/dev/Convert-ALC-Output.ps1). Just pass the log into the script.

0 comments on commit 252d062

Please sign in to comment.