Skip to content

Commit

Permalink
💚 use independent cache for vald-base
Browse files Browse the repository at this point in the history
Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com>
  • Loading branch information
rinx committed Oct 1, 2020
1 parent 57aeb36 commit 342d715
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 5 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/dockers-agent-ngt-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ jobs:
uses: docker/setup-buildx-action@v1
with:
buildkitd-flags: "--debug"
- name: Cache Docker layers: base
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache-base
key: ${{ runner.os }}-buildx-vald-base-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-vald-base-
- name: Cache Docker layers
uses: actions/cache@v2
with:
Expand Down Expand Up @@ -98,19 +105,22 @@ jobs:
make \
DOCKER="docker buildx" \
DOCKER_OPTS="--platform ${PLATFORMS} --builder ${BUILDER} ${CACHE_OPTS} ${LABEL_OPTS} --push" \
DOCKER_OPTS_BASE="--platform ${PLATFORMS} --builder ${BUILDER} ${CACHE_OPTS_BASE}" \
TAG="${PRIMARY_TAG}" \
docker/build/agent-ngt
make \
REPO="ghcr.io/vdaas/vald" \
DOCKER="docker buildx" \
DOCKER_OPTS="--platform ${PLATFORMS} --builder ${BUILDER} ${CACHE_OPTS} ${LABEL_OPTS} --push" \
DOCKER_OPTS_BASE="--platform ${PLATFORMS} --builder ${BUILDER} ${CACHE_OPTS_BASE}" \
TAG="${PRIMARY_TAG}" \
docker/build/agent-ngt
env:
DOCKER_BUILDKIT: 1
PLATFORMS: linux/amd64,linux/arm64
BUILDER: ${{ steps.buildx.outputs.name }}
CACHE_OPTS: "--cache-from=type=local,src=/tmp/.buildx-cache --cache-to=type=local,mode=max,dest=/tmp/.buildx-cache"
CACHE_OPTS_BASE: "--cache-from=type=local,src=/tmp/.buildx-cache-base --cache-to=type=local,mode=max,dest=/tmp/.buildx-cache-base"
LABEL_OPTS: "--label org.opencontainers.image.url=${{ github.event.repository.html_url }} --label org.opencontainers.image.source=${{ github.event.repository.html_url }} --label org.opencontainers.image.revision=${{ github.sha }}"
- name: Initialize CodeQL
if: startsWith( github.ref, 'refs/tags/')
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/dockers-agent-sidecar-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ jobs:
uses: docker/setup-buildx-action@v1
with:
buildkitd-flags: "--debug"
- name: Cache Docker layers: base
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache-base
key: ${{ runner.os }}-buildx-vald-base-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-vald-base-
- name: Cache Docker layers
uses: actions/cache@v2
with:
Expand Down Expand Up @@ -98,19 +105,22 @@ jobs:
make \
DOCKER="docker buildx" \
DOCKER_OPTS="--platform ${PLATFORMS} --builder ${BUILDER} ${CACHE_OPTS} ${LABEL_OPTS} --push" \
DOCKER_OPTS_BASE="--platform ${PLATFORMS} --builder ${BUILDER} ${CACHE_OPTS_BASE}" \
TAG="${PRIMARY_TAG}" \
docker/build/agent-sidecar
make \
REPO="ghcr.io/vdaas/vald" \
DOCKER="docker buildx" \
DOCKER_OPTS="--platform ${PLATFORMS} --builder ${BUILDER} ${CACHE_OPTS} ${LABEL_OPTS} --push" \
DOCKER_OPTS_BASE="--platform ${PLATFORMS} --builder ${BUILDER} ${CACHE_OPTS_BASE}" \
TAG="${PRIMARY_TAG}" \
docker/build/agent-sidecar
env:
DOCKER_BUILDKIT: 1
PLATFORMS: linux/amd64,linux/arm64
BUILDER: ${{ steps.buildx.outputs.name }}
CACHE_OPTS: "--cache-from=type=local,src=/tmp/.buildx-cache --cache-to=type=local,mode=max,dest=/tmp/.buildx-cache"
CACHE_OPTS_BASE: "--cache-from=type=local,src=/tmp/.buildx-cache-base --cache-to=type=local,mode=max,dest=/tmp/.buildx-cache-base"
LABEL_OPTS: "--label org.opencontainers.image.url=${{ github.event.repository.html_url }} --label org.opencontainers.image.source=${{ github.event.repository.html_url }} --label org.opencontainers.image.revision=${{ github.sha }}"
- name: Initialize CodeQL
if: startsWith( github.ref, 'refs/tags/')
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dockers-base-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ jobs:
run: |
make \
DOCKER="docker buildx" \
DOCKER_OPTS="--platform ${PLATFORMS} --builder ${BUILDER} ${CACHE_OPTS} ${LABEL_OPTS} --push" \
DOCKER_OPTS_BASE="--platform ${PLATFORMS} --builder ${BUILDER} ${CACHE_OPTS} ${LABEL_OPTS} --push" \
TAG="${PRIMARY_TAG}" \
docker/build/base
make \
REPO="ghcr.io/vdaas/vald" \
DOCKER="docker buildx" \
DOCKER_OPTS="--platform ${PLATFORMS} --builder ${BUILDER} ${CACHE_OPTS} ${LABEL_OPTS} --push" \
DOCKER_OPTS_BASE="--platform ${PLATFORMS} --builder ${BUILDER} ${CACHE_OPTS} ${LABEL_OPTS} --push" \
TAG="${PRIMARY_TAG}" \
docker/build/base
env:
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/dockers-ci-container-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ jobs:
uses: docker/setup-buildx-action@v1
with:
buildkitd-flags: "--debug"
- name: Cache Docker layers: base
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache-base
key: ${{ runner.os }}-buildx-vald-base-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-vald-base-
- name: Cache Docker layers
uses: actions/cache@v2
with:
Expand Down Expand Up @@ -73,17 +80,20 @@ jobs:
make \
DOCKER="docker buildx" \
DOCKER_OPTS="--platform ${PLATFORMS} --builder ${BUILDER} ${CACHE_OPTS} ${LABEL_OPTS} --push" \
DOCKER_OPTS_BASE="--platform ${PLATFORMS} --builder ${BUILDER} ${CACHE_OPTS_BASE}" \
TAG="${PRIMARY_TAG}" \
docker/build/ci-container
make \
REPO="ghcr.io/vdaas/vald" \
DOCKER="docker buildx" \
DOCKER_OPTS="--platform ${PLATFORMS} --builder ${BUILDER} ${CACHE_OPTS} ${LABEL_OPTS} --push" \
DOCKER_OPTS_BASE="--platform ${PLATFORMS} --builder ${BUILDER} ${CACHE_OPTS_BASE}" \
TAG="${PRIMARY_TAG}" \
docker/build/ci-container
env:
DOCKER_BUILDKIT: 1
PLATFORMS: linux/amd64,linux/arm64
BUILDER: ${{ steps.buildx.outputs.name }}
CACHE_OPTS: "--cache-from=type=local,src=/tmp/.buildx-cache --cache-to=type=local,mode=max,dest=/tmp/.buildx-cache"
CACHE_OPTS_BASE: "--cache-from=type=local,src=/tmp/.buildx-cache-base --cache-to=type=local,mode=max,dest=/tmp/.buildx-cache-base"
LABEL_OPTS: "--label org.opencontainers.image.url=${{ github.event.repository.html_url }} --label org.opencontainers.image.source=${{ github.event.repository.html_url }} --label org.opencontainers.image.revision=${{ github.sha }}"
10 changes: 10 additions & 0 deletions .github/workflows/dockers-dev-container-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ jobs:
uses: docker/setup-buildx-action@v1
with:
buildkitd-flags: "--debug"
- name: Cache Docker layers: base
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache-base
key: ${{ runner.os }}-buildx-vald-base-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-vald-base-
- name: Cache Docker layers
uses: actions/cache@v2
with:
Expand Down Expand Up @@ -73,17 +80,20 @@ jobs:
make \
DOCKER="docker buildx" \
DOCKER_OPTS="--platform ${PLATFORMS} --builder ${BUILDER} ${CACHE_OPTS} ${LABEL_OPTS} --push" \
DOCKER_OPTS_BASE="--platform ${PLATFORMS} --builder ${BUILDER} ${CACHE_OPTS_BASE}" \
TAG="${PRIMARY_TAG}" \
docker/build/dev-container
make \
REPO="ghcr.io/vdaas/vald" \
DOCKER="docker buildx" \
DOCKER_OPTS="--platform ${PLATFORMS} --builder ${BUILDER} ${CACHE_OPTS} ${LABEL_OPTS} --push" \
DOCKER_OPTS_BASE="--platform ${PLATFORMS} --builder ${BUILDER} ${CACHE_OPTS_BASE}" \
TAG="${PRIMARY_TAG}" \
docker/build/dev-container
env:
DOCKER_BUILDKIT: 1
PLATFORMS: linux/amd64,linux/arm64
BUILDER: ${{ steps.buildx.outputs.name }}
CACHE_OPTS: "--cache-from=type=local,src=/tmp/.buildx-cache --cache-to=type=local,mode=max,dest=/tmp/.buildx-cache"
CACHE_OPTS_BASE: "--cache-from=type=local,src=/tmp/.buildx-cache-base --cache-to=type=local,mode=max,dest=/tmp/.buildx-cache-base"
LABEL_OPTS: "--label org.opencontainers.image.url=${{ github.event.repository.html_url }} --label org.opencontainers.image.source=${{ github.event.repository.html_url }} --label org.opencontainers.image.revision=${{ github.sha }}"
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@ GO_SOURCES_INTERNAL = $(eval GO_SOURCES_INTERNAL := $(shell find \
GO_TEST_SOURCES = $(GO_SOURCES:%.go=%_test.go)
GO_OPTION_TEST_SOURCES = $(GO_OPTION_SOURCES:%.go=%_test.go)

DOCKER ?= docker
DOCKER_OPTS ?=
DOCKER ?= docker
DOCKER_OPTS ?=
DOCKER_OPTS_BASE ?=

DISTROLESS_IMAGE ?= gcr.io/distroless/static
DISTROLESS_IMAGE_TAG ?= nonroot
Expand Down
2 changes: 1 addition & 1 deletion Makefile.d/docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ docker/name/base:
## build base image
docker/build/base:
$(DOCKER) build \
$(DOCKER_OPTS) \
$(DOCKER_OPTS_BASE) \
-f dockers/base/Dockerfile \
-t $(REPO)/$(BASE_IMAGE):$(TAG) . \
--build-arg GO_VERSION=$(GO_VERSION)
Expand Down

0 comments on commit 342d715

Please sign in to comment.