Skip to content

Commit

Permalink
squash-me, implement read-only cache for pull requests; undo hardcode…
Browse files Browse the repository at this point in the history
…d params in Makefile
  • Loading branch information
jiridanek committed May 31, 2024
1 parent 266e9ac commit 6243293
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/build-notebooks-TEMPLATE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ name: Build & Publish Notebook Servers (TEMPLATE)
jobs:
build:
runs-on: ubuntu-latest
env:
# GitHub image registry used for storing $(CONTAINER_ENGINE)'s cache
CACHE: "ghcr.io/${{ github.repository }}/workbench-images/build-cache"

steps:

- uses: actions/checkout@v4

- name: Login to GitHub Container Registry
Expand Down Expand Up @@ -67,7 +72,7 @@ jobs:
env:
IMAGE_TAG: "${{ github.ref_name }}_${{ github.sha }}"
IMAGE_REGISTRY: "ghcr.io/${{ github.repository }}/workbench-images"
CACHE: "ghcr.io/${{ github.repository }}/workbench-images/build-cache"
CONTAINER_BUILD_CACHE_ARGS: "--cache-from ${{ env.CACHE }} --cache-to ${{ env.CACHE }}"

# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
- name: "pull_request: make ${{ inputs.target }}"
Expand All @@ -76,7 +81,7 @@ jobs:
env:
IMAGE_TAG: "${{ github.head_ref }}_${{ github.sha }}"
IMAGE_REGISTRY: "ghcr.io/${{ github.repository }}/workbench-images/pr${{ fromJson(inputs.github).event.number }}"
CACHE: "ghcr.io/${{ github.repository }}/workbench-images/build-cache"
CONTAINER_BUILD_CACHE_ARGS: "--cache-from ${{ env.CACHE }}"

- run: df -h
if: "${{ !cancelled() }}"
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
IMAGE_REGISTRY ?= quay.io/opendatahub/workbench-images
RELEASE ?= 2024a
# additional user-specified caching parameters for $(CONTAINER_ENGINE) build
CONTAINER_BUILD_CACHE_ARGS ?= --no-cache

# OS dependant: Generate date, select appropriate cmd to locate container engine
ifeq ($(OS), Windows_NT)
Expand Down Expand Up @@ -41,7 +43,7 @@ define build_image
$(eval BUILD_ARGS := --build-arg BASE_IMAGE=$(BASE_IMAGE_NAME)),
$(eval BUILD_ARGS :=)
)
$(CONTAINER_ENGINE) build --cache-from $(CACHE) --cache-to $(CACHE) -t $(IMAGE_NAME) $(BUILD_ARGS) $(2)
$(CONTAINER_ENGINE) build $(CONTAINER_BUILD_CACHE_ARGS) -t $(IMAGE_NAME) $(BUILD_ARGS) $(2)
endef

# Push function for the notebok image:
Expand Down

0 comments on commit 6243293

Please sign in to comment.