Skip to content

Commit

Permalink
[Ubuntu] don't configure/test docker server
Browse files Browse the repository at this point in the history
Inside container environment we're not running a second service process,
but use service container for act instead.

See: nektos/act#1949
Signed-off-by: You-Sheng Yang <vicamo@gmail.com>
  • Loading branch information
vicamo committed Mar 3, 2024
1 parent bfdca40 commit ccdbb0f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 32 deletions.
63 changes: 34 additions & 29 deletions images/ubuntu/scripts/build/install-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,35 +47,40 @@ done
# docker from official repo introduced different GID generation: https://github.com/actions/runner-images/issues/8157
gid=$(cut -d ":" -f 3 /etc/group | grep "^1..$" | sort -n | tail -n 1 | awk '{ print $1+1 }')
groupmod -g "$gid" docker
chgrp -hR docker /run/docker.sock

# Enable docker.service
systemctl is-active --quiet docker.service || systemctl start docker.service
systemctl is-enabled --quiet docker.service || systemctl enable docker.service

# Docker daemon takes time to come up after installing
sleep 10
docker info

if [[ "${DOCKERHUB_PULL_IMAGES:-yes}" == "yes" ]]; then
# If credentials are provided, attempt to log into Docker Hub
# with a paid account to avoid Docker Hub's rate limit.
if [[ "${DOCKERHUB_LOGIN}" ]] && [[ "${DOCKERHUB_PASSWORD}" ]]; then
docker login --username "${DOCKERHUB_LOGIN}" --password "${DOCKERHUB_PASSWORD}"
adduser runneradmin docker
adduser runner docker

if [[ ! -f /run/systemd/container ]]; then
chgrp -hR docker /run/docker.sock

# Enable docker.service
systemctl is-active --quiet docker.service || systemctl start docker.service
systemctl is-enabled --quiet docker.service || systemctl enable docker.service

# Docker daemon takes time to come up after installing
sleep 10
docker info

if [[ "${DOCKERHUB_PULL_IMAGES:-yes}" == "yes" ]]; then
# If credentials are provided, attempt to log into Docker Hub
# with a paid account to avoid Docker Hub's rate limit.
if [[ "${DOCKERHUB_LOGIN}" ]] && [[ "${DOCKERHUB_PASSWORD}" ]]; then
docker login --username "${DOCKERHUB_LOGIN}" --password "${DOCKERHUB_PASSWORD}"
fi

# Pull images
images=$(get_toolset_value '.docker.images[]')
for image in $images; do
docker pull "$image"
done

# Always attempt to logout so we do not leave our credentials on the built
# image. Logout _should_ return a zero exit code even if no credentials were
# stored from earlier.
docker logout
else
echo "Skipping docker images pulling"
fi

# Pull images
images=$(get_toolset_value '.docker.images[]')
for image in $images; do
docker pull "$image"
done

# Always attempt to logout so we do not leave our credentials on the built
# image. Logout _should_ return a zero exit code even if no credentials were
# stored from earlier.
docker logout
else
echo "Skipping docker images pulling"
fi

# Download amazon-ecr-credential-helper
Expand All @@ -95,6 +100,6 @@ rm $GPG_KEY
rm $REPO_PATH
invoke_tests "Tools" "Docker"
if [[ "${DOCKERHUB_PULL_IMAGES:-yes}" == "yes" ]]; then
if [[ ! -f /run/systemd/container ]] && [[ "${DOCKERHUB_PULL_IMAGES:-yes}" == "yes" ]]; then
invoke_tests "Tools" "Docker images"
fi
4 changes: 3 additions & 1 deletion images/ubuntu/scripts/docs-gen/Generate-SoftwareReport.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ $androidTools = $installedSoftware.AddHeader("Android")
$androidTools.AddTable($(Build-AndroidTable))
$androidTools.AddHeader("Environment variables").AddTable($(Build-AndroidEnvironmentTable))

$installedSoftware.AddHeader("Cached Docker images").AddTable($(Get-CachedDockerImagesTableData))
if (-not (Test-IsContainer)) {
$installedSoftware.AddHeader("Cached Docker images").AddTable($(Get-CachedDockerImagesTableData))
}
$installedSoftware.AddHeader("Installed apt packages").AddTable($(Get-AptPackages))

$softwareReport.ToJson() | Out-File -FilePath "${OutputDirectory}/software-report.json" -Encoding UTF8NoBOM
Expand Down
4 changes: 3 additions & 1 deletion images/ubuntu/scripts/docs-gen/SoftwareReport.Tools.psm1
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"

function Get-AnsibleVersion {
$ansibleVersion = (ansible --version)[0] -replace "[^\d.]"
return $ansibleVersion
Expand Down Expand Up @@ -74,7 +76,7 @@ function Get-DockerClientVersion {
}

function Get-DockerServerVersion {
$dockerServerVersion = sudo docker version --format '{{.Server.Version}}'
$dockerServerVersion = dockerd --version | Get-StringPart -Part 2 | Get-StringPart -Part 0 -Delimiter ","
return $dockerServerVersion
}

Expand Down
2 changes: 1 addition & 1 deletion images/ubuntu/scripts/tests/Tools.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Describe "Docker" {
}
}

Describe "Docker images" {
Describe "Docker images" -Skip:(Test-IsContainer) {
$testCases = (Get-ToolsetContent).docker.images | ForEach-Object { @{ ImageName = $_ } }

It "<ImageName>" -TestCases $testCases {
Expand Down

0 comments on commit ccdbb0f

Please sign in to comment.