Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tools to base #506

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

surajssd
Copy link
Member

@surajssd surajssd commented Oct 29, 2024

For better understanding the changes, look at the changes commit by commit.

Consolidate env vars into using the new `ENV`
syntax.

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
- Move dockerfile instructions from tools to base
that won't change from base image to tools image,
that would remain static. This is to ensure that
the override that we do in tools is minimal.

- In tools, consolidate the az cli and related
  installation into one RUN instruction.

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
@surajssd
Copy link
Member Author

surajssd commented Oct 29, 2024

Images built off of this PR, that you can try, base:

ghcr.io/surajssd/cloudshell/base:add-tools-to-base-3496268-20241029-000708

and tools:

ghcr.io/surajssd/cloudshell/tools:add-tools-to-base-3496268-20241029-000708

Above images have following az cli version:

$ docker run -it ghcr.io/surajssd/cloudshell/base:add-tools-to-base-3496268-20241029-000708 az version --output json | jq -r '."azure-cli"'
2.65.0

$ docker run -it ghcr.io/surajssd/cloudshell/tools:add-tools-to-base-3496268-20241029-000708 az version --output json | jq -r '."azure-cli"'
2.65.0

@surajssd
Copy link
Member Author

Since az cli now has a new release, I built a new tools image based off of the above base image which is shipping 2.65.0 and the new tools image can override the base with new az cli version, build the new tools image:

docker build \
   -t tools_cloudshell \
   --build-arg IMAGE_LOCATION=ghcr.io/surajssd/cloudshell/base:add-tools-to-base-3496268-20241029-000708 \
   -f linux/tools.Dockerfile .
$ docker run -it tools_cloudshell az version --output json | jq -r '."azure-cli"'
2.66.0

@surajssd
Copy link
Member Author

Azure CLI is being overridden, but the powershell fails:

$ docker run \
   --volume $(pwd)/tests:/tests \
   -it tools_cloudshell \
   /tests/test.sh
Creating user
running root-level tests

Starting discovery in 1 files.
Discovery found 1 tests in 165ms.
Running tests.
[+] /tests/Root.Tests.ps1 56.85s (56.51s|203ms)
Tests completed in 56.86s
Tests Passed: 1, Failed: 0, Skipped: 0, Inconclusive: 0, NotRun: 0
running tests as csuser
WARNING: The version '5.6.1' of module 'Pester' is currently in use. Retry the operation after closing the applications.

Starting discovery in 1 files.
Discovery found 32 tests in 168ms.
Running tests.

[notice] A new release of pip is available: 23.0.1 -> 24.3.1
[notice] To update, run: pip install --upgrade pip
[-] PowerShell Modules.Single version of Modules are installed 210ms (209ms|1ms)
 Expected $null, but got @(Microsoft.PowerShell.Commands.GroupInfo, Microsoft.PowerShell.Commands.GroupInfo, Microsoft.PowerShell.Commands.GroupInfo, Microsoft.PowerShell.Commands.GroupInfo, Microsoft.PowerShell.Commands.GroupInfo, Microsoft.PowerShell.Commands.GroupInfo, Microsoft.PowerShell.Commands.GroupInfo, Microsoft.PowerShell.Commands.GroupInfo, Microsoft.PowerShell.Commands.GroupInfo, Microsoft.PowerShell.Commands.GroupInfo, ...13 more).
 at (Get-Module -ListAvailable | Group-Object Name | Where-Object { $_.Count -gt 1 } ) | Where-Object { $_.Name -notin $special} | Should -Be $null, /tests/PSinLinuxCloudShellImage.Tests.ps1:107
 at <ScriptBlock>, /tests/PSinLinuxCloudShellImage.Tests.ps1:107
Tests completed in 82.68s
Tests Passed: 31, Failed: 1, Skipped: 0, Inconclusive: 0, NotRun: 0

- Tools image overrides, az cli and the powershell installation.
- The install steps check if there is any
  difference between installed and the downloaded
  az cli version. If there is a difference the
  downloaded az cli is installed, powershell is
  also installed as a part of that step.

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
@surajssd
Copy link
Member Author

surajssd commented Nov 1, 2024

With the latest changes the tests also pass. To test this PR, build the latest tools off of the base:

docker build \
   -t tools_cloudshell \
   --build-arg IMAGE_LOCATION=ghcr.io/surajssd/cloudshell/base:add-tools-to-base-3496268-20241029-000708 \
   -f linux/tools.Dockerfile .

Run regular tests:

docker run \
   --volume $(pwd)/tests:/tests \
   -it tools_cloudshell \
   /tests/test.sh

Check the new az cli version like mentioned in: #506 (comment) and check az cli in base image to see the difference and how it is being overridden.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant