Skip to content

Commit 1e9be58

Browse files
authored
✨ Add support for multi-arch builds, including support for arm64 (e.g. Mac M1) (#195)
1 parent 6354c5f commit 1e9be58

File tree

10 files changed

+44
-90
lines changed

10 files changed

+44
-90
lines changed

.github/workflows/deploy.yml

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- cron: "0 0 * * 1"
1010

1111
jobs:
12-
build:
12+
deploy:
1313
strategy:
1414
matrix:
1515
image:
@@ -37,22 +37,34 @@ jobs:
3737
runs-on: ubuntu-latest
3838
steps:
3939
- uses: actions/[email protected]
40-
- name: Set up Python
41-
uses: actions/setup-python@v4
40+
- name: Set Dockerfile name
41+
if: matrix.image.name != 'latest'
42+
run: echo "DOCKERFILE_NAME=${{ matrix.image.name }}" >> $GITHUB_ENV
43+
- name: Set Dockerfile name latest
44+
if: matrix.image.name == 'latest'
45+
run: echo "DOCKERFILE_NAME=python${{ matrix.image.python_version }}" >> $GITHUB_ENV
46+
- name: Set up Docker Buildx
47+
uses: docker/setup-buildx-action@v1
48+
- name: Login to DockerHub
49+
uses: docker/login-action@v1
4250
with:
43-
python-version: "3.7"
44-
- name: Install Dependencies
45-
run: python3.7 -m pip install docker pytest
46-
- name: Deploy Image
47-
run: bash scripts/build-push.sh
48-
env:
49-
NAME: ${{ matrix.image.name }}
50-
PYTHON_VERSION: ${{ matrix.image.python_version }}
51-
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
52-
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
51+
username: ${{ secrets.DOCKERHUB_USERNAME }}
52+
password: ${{ secrets.DOCKERHUB_TOKEN }}
53+
- name: Get date for tags
54+
run: echo "DATE_TAG=$(date -I)" >> "$GITHUB_ENV"
55+
- name: Build and push
56+
uses: docker/build-push-action@v2
57+
with:
58+
push: true
59+
platforms: linux/amd64,linux/arm64
60+
tags: |
61+
tiangolo/uvicorn-gunicorn:${{ matrix.image.name }}
62+
tiangolo/uvicorn-gunicorn:${{ matrix.image.name }}-${{ env.DATE_TAG }}
63+
context: ./docker-images/
64+
file: ./docker-images/${{ env.DOCKERFILE_NAME }}.dockerfile
5365
- name: Docker Hub Description
5466
uses: peter-evans/dockerhub-description@v3
5567
with:
56-
username: ${{ secrets.DOCKER_USERNAME }}
57-
password: ${{ secrets.DOCKER_PASSWORD }}
68+
username: ${{ secrets.DOCKERHUB_USERNAME }}
69+
password: ${{ secrets.DOCKERHUB_TOKEN }}
5870
repository: tiangolo/uvicorn-gunicorn

.github/workflows/test.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
- cron: "0 0 * * 1"
1414

1515
jobs:
16-
build:
16+
test:
1717
strategy:
1818
matrix:
1919
image:
@@ -41,12 +41,25 @@ jobs:
4141
runs-on: ubuntu-latest
4242
steps:
4343
- uses: actions/[email protected]
44+
- name: Set Dockerfile name
45+
if: matrix.image.name != 'latest'
46+
run: echo "DOCKERFILE_NAME=${{ matrix.image.name }}" >> $GITHUB_ENV
47+
- name: Set Dockerfile name latest
48+
if: matrix.image.name == 'latest'
49+
run: echo "DOCKERFILE_NAME=python${{ matrix.image.python_version }}" >> $GITHUB_ENV
50+
- name: Build
51+
uses: docker/build-push-action@v2
52+
with:
53+
push: false
54+
tags: tiangolo/uvicorn-gunicorn:${{ matrix.image.name }}
55+
context: ./docker-images/
56+
file: ./docker-images/${{ env.DOCKERFILE_NAME }}.dockerfile
4457
- name: Set up Python
4558
uses: actions/setup-python@v4
4659
with:
47-
python-version: "3.7"
60+
python-version: "3.10"
4861
- name: Install Dependencies
49-
run: python3.7 -m pip install docker pytest
62+
run: python -m pip install docker pytest
5063
- name: Test Image
5164
run: bash scripts/test.sh
5265
env:
@@ -55,7 +68,7 @@ jobs:
5568
check:
5669
if: always()
5770
needs:
58-
- build
71+
- test
5972
runs-on: ubuntu-latest
6073
steps:
6174
- name: Decide whether the needed jobs succeeded or failed

scripts/build-push-all.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

scripts/build-push.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

scripts/build.sh

Lines changed: 0 additions & 12 deletions
This file was deleted.

scripts/deploy.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

scripts/docker-login.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

scripts/test-all.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

scripts/test.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
bash scripts/build.sh
54
pytest tests

scripts/trigger-children.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)