Skip to content

Commit

Permalink
Docker multi-arch images push for linux/amd64, linux/arm64 (#32686)
Browse files Browse the repository at this point in the history
* fix: push docker multi-arch images

---------

Co-authored-by: Salman Nawaz <[email protected]>
  • Loading branch information
salman2013 and Salman Nawaz authored Jul 27, 2023
1 parent 06e738e commit e4a1039
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 22 deletions.
29 changes: 25 additions & 4 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,35 @@ jobs:
# See also https://docs.docker.com/docker-hub/builds/
push:
runs-on: ubuntu-latest
if: github.event_name == 'push'
if: github.event_name == 'push'

strategy:
matrix:
variant:
- "lms_dev"
- "cms_dev"
- "cms"
- "lms"

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Build and Push docker image
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push lms base docker image
env:
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
run : make docker_push
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
run : make docker_tag_build_push_${{matrix.variant}}

33 changes: 15 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Do things in edx-platform
.PHONY: base-requirements check-types clean \
compile-requirements detect_changed_source_translations dev-requirements \
docker_auth docker_build docker_push docker_tag docs extract_translations \
docker_auth docker_build docker_tag_build_push_lms docker_tag_build_push_lms_dev \
docker_tag_build_push_cms docker_tag_build_push_cms_dev docs extract_translations \
guides help lint-imports local-requirements migrate migrate-lms migrate-cms \
pre-requirements pull pull_translations push_translations requirements shell swagger \
technical-docs test-requirements ubuntu-requirements upgrade-package upgrade
Expand Down Expand Up @@ -142,30 +143,26 @@ upgrade-package: ## update just one package to the latest usable release
check-types: ## run static type-checking tests
mypy

docker_build:
docker_auth:
echo "$$DOCKERHUB_PASSWORD" | docker login -u "$$DOCKERHUB_USERNAME" --password-stdin

docker_build: docker_auth
DOCKER_BUILDKIT=1 docker build . --build-arg SERVICE_VARIANT=lms --build-arg SERVICE_PORT=8000 --target development -t openedx/lms-dev
DOCKER_BUILDKIT=1 docker build . --build-arg SERVICE_VARIANT=lms --build-arg SERVICE_PORT=8000 --target production -t openedx/lms
DOCKER_BUILDKIT=1 docker build . --build-arg SERVICE_VARIANT=cms --build-arg SERVICE_PORT=8010 --target development -t openedx/cms-dev
DOCKER_BUILDKIT=1 docker build . --build-arg SERVICE_VARIANT=cms --build-arg SERVICE_PORT=8010 --target production -t openedx/cms

docker_tag: docker_build
docker tag openedx/lms openedx/lms:${GITHUB_SHA}
docker tag openedx/lms-dev openedx/lms-dev:${GITHUB_SHA}
docker tag openedx/cms openedx/cms:${GITHUB_SHA}
docker tag openedx/cms-dev openedx/cms-dev:${GITHUB_SHA}
docker_tag_build_push_lms: docker_auth
docker buildx build -t openedx/lms:latest -t openedx/lms:${GITHUB_SHA} --platform linux/amd64,linux/arm64 --build-arg SERVICE_VARIANT=lms --build-arg SERVICE_PORT=8000 --target production --push .

docker_auth:
echo "$$DOCKERHUB_PASSWORD" | docker login -u "$$DOCKERHUB_USERNAME" --password-stdin
docker_tag_build_push_lms_dev: docker_auth
docker buildx build -t openedx/lms-dev:latest -t openedx/lms-dev:${GITHUB_SHA} --platform linux/amd64,linux/arm64 --build-arg SERVICE_VARIANT=lms --build-arg SERVICE_PORT=8000 --target development --push .

docker_tag_build_push_cms: docker_auth
docker buildx build -t openedx/cms:latest -t openedx/cms:${GITHUB_SHA} --platform linux/amd64,linux/arm64 --build-arg SERVICE_VARIANT=cms --build-arg SERVICE_PORT=8010 --target production --push .

docker_push: docker_tag docker_auth ## push to docker hub
docker push "openedx/lms:latest"
docker push "openedx/lms:${GITHUB_SHA}"
docker push "openedx/lms-dev:latest"
docker push "openedx/lms-dev:${GITHUB_SHA}"
docker push "openedx/cms:latest"
docker push "openedx/cms:${GITHUB_SHA}"
docker push "openedx/cms-dev:latest"
docker push "openedx/cms-dev:${GITHUB_SHA}"
docker_tag_build_push_cms_dev: docker_auth
docker buildx build -t openedx/cms-dev:latest -t openedx/cms-dev:${GITHUB_SHA} --platform linux/amd64,linux/arm64 --build-arg SERVICE_VARIANT=cms --build-arg SERVICE_PORT=8010 --target development --push .

lint-imports:
lint-imports
Expand Down

0 comments on commit e4a1039

Please sign in to comment.