From 83e9552bf0ed9ae6ae02f6aaf98a15d8c758d848 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Wed, 8 Sep 2021 15:14:57 +0300 Subject: [PATCH] Revert "Revert "docker/windows: build rust image in the ci"" This reverts commit 3f17e16c72409be5d9c257aefc1abd09c4e26b8b. Part-of: --- docker/windows/build_image.ps1 | 19 +------------ docker/windows/container.ps1 | 4 +-- docker/windows/rust.Dockerfile | 5 +++- gitlab/ci_template.yml | 50 ++++++++++++++++++++++++++++++++-- 4 files changed, 54 insertions(+), 24 deletions(-) diff --git a/docker/windows/build_image.ps1 b/docker/windows/build_image.ps1 index 37ffe02ce2..a4be56c1fa 100644 --- a/docker/windows/build_image.ps1 +++ b/docker/windows/build_image.ps1 @@ -1,7 +1,7 @@ $env:ErrorActionPreference='Stop' $env:DEFAULT_BRANCH='master' -$env:VERSION='v18' +$env:VERSION='test' $env:tag ="registry.freedesktop.org/gstreamer/gst-ci/amd64/windows:$env:VERSION-$env:DEFAULT_BRANCH" $env:rust_tag ="registry.freedesktop.org/gstreamer/gst-ci/amd64/windows-rust:$env:VERSION-$env:DEFAULT_BRANCH" @@ -23,22 +23,5 @@ if (!$?) { Exit 1 } -# Get-Date -# Write-Output "Pushing $env:tag" -# docker push $env:tag -# if (!$?) { -# Write-Host "Failed to push docker image $env:tag" -# Exit 1 -# } - -# Get-Date -# Write-Output "Pushing $env:rust_tag" -# docker push $env:rust_tag -# if (!$?) { -# Write-Host "Failed to push docker image $env:rust_tag" -# Exit 1 -# } - - Get-Date Write-Output "Build Finished" \ No newline at end of file diff --git a/docker/windows/container.ps1 b/docker/windows/container.ps1 index fac0087f99..e5dc2cd835 100644 --- a/docker/windows/container.ps1 +++ b/docker/windows/container.ps1 @@ -13,8 +13,6 @@ $registry_user_image = $args[3] $registry_central_image = $args[4] $dockerfile = $args[5] -Set-Location -Path ".\docker\windows" - docker --config "windows-docker.conf" login -u "$registry_username" -p "$registry_password" "$registry_uri" if (!$?) { Write-Host "docker login failed to $registry_uri" @@ -45,7 +43,7 @@ if ($?) { } Write-Host "No image found at $registry_user_image or $registry_central_image; rebuilding" -docker --config "windows-docker.conf" build --no-cache -t "$registry_user_image" -f "$dockerfile" . +docker --config "windows-docker.conf" build $DOCKER_BUILD_ARGS --no-cache -t "$registry_user_image" -f "$dockerfile" "./docker/windows" if (!$?) { Write-Host "Container build failed" docker --config "windows-docker.conf" logout "$registry_uri" diff --git a/docker/windows/rust.Dockerfile b/docker/windows/rust.Dockerfile index 7ccfaffee9..6d52353788 100644 --- a/docker/windows/rust.Dockerfile +++ b/docker/windows/rust.Dockerfile @@ -1,6 +1,9 @@ # escape=` -FROM 'registry.freedesktop.org/gstreamer/gst-ci/amd64/windows:v16-master' +# Expect this to be set when calling docker build with +# --build-arg BASE_IMAGE="" and make it fail if not set. +ARG BASE_IMAGE="inavlid.gstreamer.freedesktop.org/invalid" +FROM $BASE_IMAGE ARG DEFAULT_BRANCH="master" ARG RUST_VERSION="1.52.1" diff --git a/gitlab/ci_template.yml b/gitlab/ci_template.yml index 308af0ed0c..8435c0ed88 100644 --- a/gitlab/ci_template.yml +++ b/gitlab/ci_template.yml @@ -3,6 +3,7 @@ include: stages: - 'build docker' + - 'build docker stage 2' - 'preparation' - 'pre-build' - 'build' @@ -38,6 +39,7 @@ variables: TEST_MANIFEST_AMD64_SUFFIX: 'amd64/test-manifest' INDENT_AMD64_SUFFIX: 'amd64/gst-indent' WINDOWS_AMD64_SUFFIX: 'amd64/windows' + WINDOWS_RUST_AMD64_SUFFIX: 'amd64/windows-rust' FEDORA_IMAGE: "$CI_REGISTRY_IMAGE/$FEDORA_AMD64_SUFFIX:$FEDORA_TAG-$GST_UPSTREAM_BRANCH" FEDORA_DOCS_IMAGE: "registry.freedesktop.org/gstreamer/gst-ci/amd64/fedora:2020-07-03.0-master" @@ -48,6 +50,8 @@ variables: INDENT_IMAGE: "$CI_REGISTRY_IMAGE/$INDENT_AMD64_SUFFIX:$INDENT_TAG-$GST_UPSTREAM_BRANCH" WINDOWS_IMAGE: "$CI_REGISTRY_IMAGE/$WINDOWS_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH" WINDOWS_UPSTREAM_IMAGE: "$CI_REGISTRY/$GST_UPSTREAM_REPO/$WINDOWS_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH" + WINDOWS_RUST_IMAGE: "$CI_REGISTRY_IMAGE/$WINDOWS_RUST_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH" + WINDOWS_RUST_UPSTREAM_IMAGE: "$CI_REGISTRY/$GST_UPSTREAM_REPO/$WINDOWS_RUST_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH" # Current windows image doesn't seem to be able to spawn procceses for reason, # use a different image until this is debuged @@ -57,7 +61,9 @@ variables: # Can't use $CI_* variables since we use this template in all repos, not just gst-ci CERBERO_SCRIPT_URL: "https://gitlab.freedesktop.org/gstreamer/gst-ci/raw/${GST_UPSTREAM_BRANCH}/gitlab/cerbero_setup.sh" - WINDOWS_CONTAINER_SCRIPT_URL: "https://gitlab.freedesktop.org/gstreamer/gst-ci/raw/${GST_UPSTREAM_BRANCH}/docker/windows/container.ps1" + # FIXME: fix the file path url to point to the upstram once merged + # WINDOWS_CONTAINER_SCRIPT_URL: "https://gitlab.freedesktop.org/gstreamer/gst-ci/raw/${GST_UPSTREAM_BRANCH}/docker/windows/container.ps1" + WINDOWS_CONTAINER_SCRIPT_URL: "https://gitlab.freedesktop.org/alatiera/gst-ci/raw/alatiera/windows-rs-wip/docker/windows/container.ps1" GIT_STRATEGY: none MESON_BUILDTYPE_ARGS: --default-library=both @@ -349,12 +355,15 @@ windows amd64 docker: # # We also don't need a CONTEXT_DIR var as its also # hardcoded to be docker/windows/ - DOCKERFILE: "Dockerfile" + DOCKERFILE: "docker/windows/Dockerfile" tags: - windows - shell - "1809" script: + # We need to pass an array and to resolve the env vars, so we can't use a variable: + - $DOCKER_BUILD_ARGS = @("--build-arg", "DEFAULT_BRANCH=$GST_UPSTREAM_BRANCH") + - $env:WINDOWS_CONTAINER_SCRIPT_PATH = "$env:CI_PROJECT_DIR\container.ps1" - echo "Fetching $env:WINDOWS_CONTAINER_SCRIPT_URL" - Invoke-WebRequest -Uri $env:WINDOWS_CONTAINER_SCRIPT_URL -OutFile $env:WINDOWS_CONTAINER_SCRIPT_PATH @@ -366,6 +375,43 @@ windows amd64 docker: Exit 1 } +windows rust amd64 docker: + stage: 'build docker stage 2' + needs: + - job: 'windows amd64 docker' + artifacts: false + variables: + GIT_STRATEGY: 'fetch' + REPO_SUFFIX: "$WINDOWS_RUST_AMD64_SUFFIX" + TAG: "$WINDOWS_TAG-$GST_UPSTREAM_BRANCH" + + # Unlike the buildah/linux jobs, this file + # needs to be relative to docker/windows/ subdir + # as it makes life easier in the powershell script + # + # We also don't need a CONTEXT_DIR var as its also + # hardcoded to be docker/windows/ + DOCKERFILE: 'docker/windows/rust.Dockerfile' + tags: + - 'windows' + - 'shell' + - '1809' + script: + # We need to pass an array and to resolve the env vars, so we can't use a variable: + - $DOCKER_BUILD_ARGS = @("--build-arg", "DEFAULT_BRANCH=$GST_UPSTREAM_BRANCH", "--build-arg", "BASE_IMAGE=$WINDOWS_IMAGE") + + - $env:WINDOWS_CONTAINER_SCRIPT_PATH = "$env:CI_PROJECT_DIR\container.ps1" + - echo "Fetching $env:WINDOWS_CONTAINER_SCRIPT_URL" + - Invoke-WebRequest -Uri $env:WINDOWS_CONTAINER_SCRIPT_URL -OutFile $env:WINDOWS_CONTAINER_SCRIPT_PATH + + - "& $env:WINDOWS_CONTAINER_SCRIPT_PATH $CI_REGISTRY $CI_REGISTRY_USER $CI_REGISTRY_PASSWORD $WINDOWS_RUST_IMAGE $WINDOWS_RUST_UPSTREAM_IMAGE $DOCKERFILE" + - | + if (!($?)) { + echo "Failed to build the image" + Exit 1 + } + + # # Job to create the manifest.xml to used for our builds #