Skip to content

Commit

Permalink
Support arm builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayaz Salikhov committed Jul 10, 2021
1 parent 3c9e62e commit 1648a8c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
25 changes: 22 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,28 @@ jobs:
!contains(github.event.head_commit.message, 'ci skip') &&
!contains(github.event.pull_request.title, 'ci skip')
steps:
- name: Should we push this image to a public registry?
run: |
if [ "${{ startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main') }}" = "true" ]; then
# Empty => Docker Hub
echo "REGISTRY=" >> $GITHUB_ENV
else
echo "REGISTRY=localhost:5000/" >> $GITHUB_ENV
fi
# Setup docker to build for multiple platforms, see:
# https://github.com/docker/build-push-action/tree/v2.4.0#usage
# https://github.com/docker/build-push-action/blob/v2.4.0/docs/advanced/multi-platform.md

- name: Set up QEMU (for docker buildx)
uses: docker/setup-qemu-action@27d0a4f181a40b142cce983c5393082c365d1480 # dependabot updates to latest release

- name: Set up Docker Buildx (for multi-arch builds)
uses: docker/setup-buildx-action@0d135e0c2fc0dba0729c1a47ecfcf5a3c7f8579e # dependabot updates to latest release
with:
# Allows pushing to registry on localhost:5000
driver-opts: network=host

- name: Clone Main Repo
uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -67,6 +89,3 @@ jobs:
with:
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_TOKEN}}
- name: Push Images to DockerHub
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
run: make -C main push-all
29 changes: 26 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ SHELL:=bash
OWNER?=jupyter

# Need to list the images in build dependency order

# These are images we can cross-build
CROSS_IMAGES:= base-notebook \
minimal-notebook
# These images that aren't currently supported for cross-building, your help is welcome.
X86_IMAGES:= r-notebook \
scipy-notebook \
tensorflow-notebook \
datascience-notebook \
pyspark-notebook \
all-spark-notebook
# All of the images
ALL_IMAGES:=base-notebook \
minimal-notebook \
r-notebook \
Expand All @@ -27,11 +39,22 @@ help:
@echo
@grep -E '^[a-zA-Z0-9_%/-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

build/%: DARGS?=
build/%: ## build the latest image for a stack
docker build $(DARGS) --rm --force-rm -t $(OWNER)/$(notdir $@):latest --build-arg OWNER=$(OWNER) ./$(notdir $@)
build-x86/%: DARGS?=
build-x86/%: ## build the latest image for a stack
docker buildx build $(DARGS) --rm --force-rm -t $(OWNER)/$(notdir $@):latest ./$(notdir $@) --build-arg OWNER=$(OWNER) --platform "linux/amd64" --push
@echo -n "Built image size: "
@docker images $(OWNER)/$(notdir $@):latest --format "{{.Size}}"
build-test-x86-all: $(foreach I,$(X86_IMAGES), build-x86/$(I) test/$(I) ) ## build and test all stacks

build-cross/%: DARGS?=
build-cross/%: ## build the latest image for a stack on x86 and ARM
docker buildx build $(DARGS) --rm --force-rm -t $(OWNER)/$(notdir $@):latest ./$(notdir $@) --build-arg OWNER=$(OWNER) --platform "linux/amd64,linux/arm64" --push
@echo -n "Built image size: "
@docker images $(OWNER)/$(notdir $@):latest --format "{{.Size}}"
build-test-cross-all: $(foreach I,$(X86_IMAGES), build-x86/$(I) test/$(I) ) ## build and test all stacks

build-all: $(foreach I,$(CROSS_IMAGES), build-cross/$(I) ) $(foreach I,$(X86_IMAGES), build/$(I) ) ## build all stacks
build-test-all: build-all $(foreach I,$(ALL_IMAGES), test/$(I) ) ## build and test all stacks

build-all: $(foreach I,$(ALL_IMAGES), build/$(I) ) ## build all stacks
build-test-all: $(foreach I,$(ALL_IMAGES), build/$(I) test/$(I) ) ## build and test all stacks
Expand Down

0 comments on commit 1648a8c

Please sign in to comment.