From 10889dd0017eba3b3af1c7a235032e2cb400cc8c Mon Sep 17 00:00:00 2001 From: Ernesto Puerta Date: Tue, 23 Jan 2024 20:40:31 +0100 Subject: [PATCH] docker,ci: add persistent caching Signed-off-by: Ernesto Puerta --- .github/workflows/build-container.yml | 72 +++++++++++++++++---------- Makefile | 1 - docker-compose.yaml | 15 ++++++ mk/containerized.mk | 3 +- 4 files changed, 62 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build-container.yml b/.github/workflows/build-container.yml index caaedd195..97d0c7363 100644 --- a/.github/workflows/build-container.yml +++ b/.github/workflows/build-container.yml @@ -1,5 +1,6 @@ --- # yamllint disable rule:line-length +# yamllint disable rule:comments name: "CI" on: # yamllint disable rule:truthy push: @@ -20,7 +21,38 @@ concurrency: cancel-in-progress: true env: WAIT_INTERVAL_SECS: 1 + DOCKER_COMPOSE: docker compose # This is to deal with v1 (docker-compose) and v2 (docker compose) jobs: + build-ceph: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Expose GitHub Runtime + # Pinned to https://github.com/crazy-max/ghaction-github-runtime/releases/tag/v3.0.0 + # Required to expose $ACTIONS_RUNTIME_TOKEN (suggested by Docker: + # https://docs.docker.com/build/cache/backends/gha/#authentication ) + uses: crazy-max/ghaction-github-runtime@b3a9207c0e1ef41f4cf215303c976869d0c2c1c4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build container images - ceph + run: make build SVC=ceph + + - name: Save container images + run: | + . .env + docker save $QUAY_CEPH:$CEPH_VERSION > ceph.tar + + - name: Upload container images + uses: actions/upload-artifact@v4 + with: + name: container_images_ceph + path: | + ceph.tar + build: runs-on: ubuntu-latest steps: @@ -29,6 +61,15 @@ jobs: with: submodules: recursive + - name: Expose GitHub Runtime + # Pinned to https://github.com/crazy-max/ghaction-github-runtime/releases/tag/v3.0.0 + # Required to expose $ACTIONS_RUNTIME_TOKEN (suggested by Docker: + # https://docs.docker.com/build/cache/backends/gha/#authentication ) + uses: crazy-max/ghaction-github-runtime@b3a9207c0e1ef41f4cf215303c976869d0c2c1c4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build container images - spdk run: make build SVC="spdk" SPDK_TARGET_ARCH=x86-64-v2 @@ -60,27 +101,6 @@ jobs: nvmeof-cli.tar bdevperf.tar - build-ceph: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Build container images - ceph - run: make build SVC=ceph - - - name: Save container images - run: | - . .env - docker save $QUAY_CEPH:$CEPH_VERSION > ceph.tar - - - name: Upload container images - uses: actions/upload-artifact@v4 - with: - name: container_images_ceph - path: | - ceph.tar - pytest: needs: [build, build-ceph] strategy: @@ -354,7 +374,7 @@ jobs: - name: Start discovery controller if: matrix.integration == 'container' run: | - docker-compose up --detach discovery + $DOCKER_COMPOSE up --detach discovery - name: Wait for discovery controller to be listening if: matrix.integration == 'container' @@ -374,7 +394,7 @@ jobs: - name: Start gateway with scale=2 run: | - docker-compose up --detach --scale nvmeof=2 nvmeof + $DOCKER_COMPOSE up --detach --scale nvmeof=2 nvmeof - name: Wait for gateways to be listening timeout-minutes: 3 @@ -397,12 +417,12 @@ jobs: - name: List containers if: success() || failure() run: | - docker-compose ps + $DOCKER_COMPOSE ps - name: List processes if: success() || failure() run: | - docker-compose top + $DOCKER_COMPOSE top - name: Create RBD image run: | @@ -423,7 +443,7 @@ jobs: cli_gw() { gw=$1 shift - docker-compose run --rm nvmeof-cli --server-address $gw --server-port $NVMEOF_GW_PORT "$@" + $DOCKER_COMPOSE run --rm nvmeof-cli --server-address $gw --server-port $NVMEOF_GW_PORT "$@" } gw1=$(container_ip $GW1) diff --git a/Makefile b/Makefile index 6c751618d..7e632abc2 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,6 @@ build: export NVMEOF_GIT_MODIFIED_FILES != git status -s | grep -e "^ *M" | sed up: ## Launch services up: SVC ?= ceph nvmeof ## Services up: OPTS ?= --abort-on-container-exit --exit-code-from $(SVC) --remove-orphans -#up: override OPTS += --scale nvmeof=$(SCALE) clean: $(CLEAN) setup ## Clean-up environment clean: override HUGEPAGES = 0 diff --git a/docker-compose.yaml b/docker-compose.yaml index 26ccbb775..dec2916e4 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,3 +1,6 @@ +--- +# yamllint disable rule:line-length +# yamllint disable rule:comments version: "3.8" services: spdk: @@ -26,6 +29,10 @@ services: SPDK_GIT_COMMIT: labels: io.ceph.nvmeof: + cache_from: + - type=gha + cache_to: + - type=gha # Used to export RPM packages externally (via bind mount) spdk-rpm-export: extends: @@ -61,6 +68,10 @@ services: CEPH_CLUSTER_CEPH_REPO_BASEURL: labels: io.ceph.nvmeof: + cache_from: + - type=gha + cache_to: + - type=gha environment: TOUCHFILE: /tmp/ceph.touch entrypoint: >- @@ -121,6 +132,10 @@ services: HUGEPAGES_DIR: labels: io.ceph.nvmeof: + cache_from: + - type=gha + cache_to: + - type=gha volumes: # sudo bash -c 'echo 2048 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages' # https://spdk.io/doc/containers.html diff --git a/mk/containerized.mk b/mk/containerized.mk index 5669423d2..b5dfbe14d 100644 --- a/mk/containerized.mk +++ b/mk/containerized.mk @@ -2,12 +2,11 @@ # Docker and docker-compose specific commands DOCKER = docker -DOCKER_COMPOSE = docker-compose ## Docker-compose command +DOCKER_COMPOSE != echo $${DOCKER_COMPOSE:-docker-compose} ## Docker-compose command DOCKER_COMPOSE_COMMANDS = pull build up run exec ps top images logs port \ pause unpause stop restart down events OPTS ?= ## Docker-compose subcommand options -SCALE ?= 1 ## Number of instances CMD ?= ## Command to run with run/exec targets .PHONY: $(DOCKER_COMPOSE_COMMANDS) shell