diff --git a/.github/workflows/build-linux-packages.yml b/.github/workflows/build-linux-packages.yml index 0b7182e4ed..1395625a47 100644 --- a/.github/workflows/build-linux-packages.yml +++ b/.github/workflows/build-linux-packages.yml @@ -42,7 +42,7 @@ jobs: - id: define_constants run: | echo "python_version=3.8" >> "${GITHUB_OUTPUT}" - echo "cache_version=$GITHUB_REF_NAME" >> "${GITHUB_OUTPUT}" + echo "cache_version=1" >> "${GITHUB_OUTPUT}" echo "aws_region=us-east-1" >> "${GITHUB_OUTPUT}" echo "cicd_workflow=${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}" >> "${GITHUB_OUTPUT}" diff --git a/.github/workflows/retry-workflow-build-container-images.yaml b/.github/workflows/retry-workflow-build-container-images.yaml index 9452dc4a10..a35fdf3ad6 100644 --- a/.github/workflows/retry-workflow-build-container-images.yaml +++ b/.github/workflows/retry-workflow-build-container-images.yaml @@ -3,12 +3,12 @@ name: Retry Workflow Build Container Images on: push: branches: - - master + - masterx tags: - v*.*.* pull_request: branches: - - master + - masterx workflow_dispatch: schedule: diff --git a/.github/workflows/reusable-agent-build-container-images.yml b/.github/workflows/reusable-agent-build-container-images.yml index 4cdd523fad..f4dc24c52b 100644 --- a/.github/workflows/reusable-agent-build-container-images.yml +++ b/.github/workflows/reusable-agent-build-container-images.yml @@ -1080,7 +1080,7 @@ jobs: fi - name: Set up skopeo - uses: warjiang/setup-skopeo@latest + uses: warjiang/setup-skopeo@v0.1.3 with: version: latest diff --git a/agent_build_refactored/container_images/base_image_ubuntu.txt b/agent_build_refactored/container_images/base_image_ubuntu.txt index 604b4c471c..befba2550a 100644 --- a/agent_build_refactored/container_images/base_image_ubuntu.txt +++ b/agent_build_refactored/container_images/base_image_ubuntu.txt @@ -1 +1 @@ -ubuntu:20.04 \ No newline at end of file +ubuntu:22.04 diff --git a/agent_build_refactored/container_images/base_images/alpine.Dockerfile b/agent_build_refactored/container_images/base_images/alpine.Dockerfile index 017f340254..ea112ffa69 100644 --- a/agent_build_refactored/container_images/base_images/alpine.Dockerfile +++ b/agent_build_refactored/container_images/base_images/alpine.Dockerfile @@ -2,6 +2,7 @@ ARG BASE_IMAGE FROM ${BASE_IMAGE} as base FROM base as dependencies_build_base +RUN echo cache out RUN apk update && apk add --no-cache \ --virtual build-dependencies \ binutils \ diff --git a/agent_build_refactored/container_images/image_builders.py b/agent_build_refactored/container_images/image_builders.py index 2831b0f2ec..3f5b570439 100644 --- a/agent_build_refactored/container_images/image_builders.py +++ b/agent_build_refactored/container_images/image_builders.py @@ -410,11 +410,21 @@ def publish( try: cmd_args = [ - "skopeo", - "copy", - "--all", - f"oci-archive:{oci_layout_tarball}", - f"docker://{tag}" + "docker", + "import", + str(oci_layout_tarball), + tag + ] + + subprocess.run( + cmd_args, + check=True + ) + + cmd_args = [ + "docker", + "push", + tag ] subprocess.run( diff --git a/agent_build_refactored/utils/docker/buildx/build.py b/agent_build_refactored/utils/docker/buildx/build.py index 25cddd585b..da9fddb3d1 100644 --- a/agent_build_refactored/utils/docker/buildx/build.py +++ b/agent_build_refactored/utils/docker/buildx/build.py @@ -32,6 +32,7 @@ # It is also expected that GHA cache authentication environment variables are already exposed to the build process. # see more - https://docs.docker.com/build/cache/backends/gha/ USE_GHA_CACHE = bool(os.environ.get("USE_GHA_CACHE")) +USE_DOCKER_CACHE=bool(os.environ.get("USE_DOCKER_CACHE")) # Just a suffix for the build cache string. May be usefull when it is needed to invalidate the cache. CACHE_VERSION = os.environ.get("CACHE_VERSION", "") @@ -110,7 +111,7 @@ def buildx_build( "buildx", "build", f"-f={dockerfile_path}", - "--progress=plain", + "--progress=plain" ] if buildx_builder: @@ -146,6 +147,9 @@ def buildx_build( f"--cache-from=type=gha,scope={final_cache_scope}", f"--cache-to=type=gha,scope={final_cache_scope}", ]) + elif USE_DOCKER_CACHE: + # Add nothing + pass else: cache_dir = _get_local_cache_dir(name=cache_name) cmd_args.extend([ diff --git a/agent_build_refactored/utils/toolset_image/Dockerfile b/agent_build_refactored/utils/toolset_image/Dockerfile index 76e0279a90..aa674e5d40 100644 --- a/agent_build_refactored/utils/toolset_image/Dockerfile +++ b/agent_build_refactored/utils/toolset_image/Dockerfile @@ -1,7 +1,6 @@ FROM ubuntu:22.04 RUN DEBIAN_FRONTEND="noninteractive" \ apt-get update && \ - apt-get dist-upgrade --yes --no-install-recommends --no-install-suggests && \ apt-get install -y \ binutils \ tar \ diff --git a/tests/end_to_end_tests/container_images_test/tools/__init__.py b/tests/end_to_end_tests/container_images_test/tools/__init__.py index d9a49eb79e..4e3b6ef2c7 100644 --- a/tests/end_to_end_tests/container_images_test/tools/__init__.py +++ b/tests/end_to_end_tests/container_images_test/tools/__init__.py @@ -11,11 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - - +import logging import pathlib as pl import subprocess -from typing import Callable +from typing import Callable, List + +logger = logging.getLogger(__name__) from agent_build_refactored.utils.constants import CpuArch from agent_build_refactored.utils.docker.common import delete_container @@ -46,23 +47,37 @@ def build_test_version_of_container_image( tests can enable it in order to obtain coverage information of the docker/k8s related code. """ + def run(comment: str, cmd: List[str]): + logger.info(f"Running: {comment}") + logger.info(f"Command: {cmd}") + completed_process = subprocess.run( + cmd, + check=True, + capture_output=True, + ) + + logger.info(f"Completed: {comment}") + logger.info(completed_process.stdout.decode()) + logger.info(completed_process.stderr.decode()) + registry_container_name = "agent_image_e2e_test_registry" delete_container(container_name=registry_container_name) # Create temporary local registry to push production image there. - subprocess.run( - [ - "docker", - "run", - "-d", - "--rm", - "-p=5000:5000", - f"--name={registry_container_name}", - "registry:2", - ], - check=True, - ) + cmd = [ + "docker", + "run", + "-d", + "--rm", + "-p=5000:5000", + f"--name={registry_container_name}", + "registry:2", + ] + + run(f"Creating local registry container.", cmd) + + try: all_image_tags = image_builder.generate_final_registry_tags( image_type=image_type, @@ -72,6 +87,7 @@ def build_test_version_of_container_image( ) # Publish image to the local registry + logger.info(f"Publishing image to the local registry: {all_image_tags}") image_builder.publish( image_type=image_type, tags=all_image_tags,