Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add support for multiarch builds, including ARM (e.g. Mac M1) #138

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 28 additions & 17 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- cron: "0 0 * * 1"

jobs:
build:
deploy:
strategy:
matrix:
image:
Expand All @@ -24,24 +24,35 @@ jobs:
fail-fast: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
- uses: actions/checkout@v4
- name: Set Dockerfile name
if: matrix.image.name != 'latest'
run: echo "DOCKERFILE_NAME=${{ matrix.image.name }}" >> $GITHUB_ENV
- name: Set Dockerfile name latest
if: matrix.image.name == 'latest'
run: echo "DOCKERFILE_NAME=python${{ matrix.image.python_version }}" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
python-version: "3.7"
- name: Install Dependencies
run: python3.7 -m pip install docker pytest
- name: Deploy Image
run: bash scripts/build-push.sh
env:
NAME: ${{ matrix.image.name }}
DOCKERFILE: ${{ matrix.image.dockerfile }}
PYTHON_VERSION: ${{ matrix.image.python_version }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get date for tags
run: echo "DATE_TAG=$(date -I)" >> "$GITHUB_ENV"
- name: Build and push
uses: docker/build-push-action@v2
with:
push: true
platforms: linux/amd64,linux/arm64
tags: |
tiangolo/meinheld-gunicorn-flask:${{ matrix.image.name }}
tiangolo/meinheld-gunicorn-flask:${{ matrix.image.name }}-${{ env.DATE_TAG }}
context: ./docker-images/
file: ./docker-images/${{ env.DOCKERFILE_NAME }}.dockerfile
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: tiangolo/meinheld-gunicorn-flask
24 changes: 18 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- cron: "0 0 * * 1"

jobs:
build:
test:
strategy:
matrix:
image:
Expand All @@ -28,23 +28,35 @@ jobs:
fail-fast: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set Dockerfile name
if: matrix.image.name != 'latest'
run: echo "DOCKERFILE_NAME=${{ matrix.image.name }}" >> $GITHUB_ENV
- name: Set Dockerfile name latest
if: matrix.image.name == 'latest'
run: echo "DOCKERFILE_NAME=python${{ matrix.image.python_version }}" >> $GITHUB_ENV
- name: Build
uses: docker/build-push-action@v2
with:
push: false
tags: tiangolo/meinheld-gunicorn-flask:${{ matrix.image.name }}
context: ./docker-images/
file: ./docker-images/${{ env.DOCKERFILE_NAME }}.dockerfile
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.7"
python-version: "3.10"
- name: Install Dependencies
run: python3.7 -m pip install docker pytest
run: python -m pip install docker pytest
- name: Test Image
run: bash scripts/test.sh
env:
NAME: ${{ matrix.image.name }}
DOCKERFILE: ${{ matrix.image.dockerfile }}
PYTHON_VERSION: ${{ matrix.image.python_version }}
check:
if: always()
needs:
- build
- test
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
Expand Down
7 changes: 0 additions & 7 deletions scripts/build-push-all.sh

This file was deleted.

15 changes: 0 additions & 15 deletions scripts/build-push.sh

This file was deleted.

12 changes: 0 additions & 12 deletions scripts/build.sh

This file was deleted.

5 changes: 0 additions & 5 deletions scripts/docker-login.sh

This file was deleted.

4 changes: 0 additions & 4 deletions scripts/test-all.sh

This file was deleted.

1 change: 0 additions & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
set -e

bash scripts/build.sh
pytest tests
Loading