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) #200

Merged
merged 5 commits 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
47 changes: 29 additions & 18 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 @@ -28,24 +28,35 @@ jobs:
fail-fast: true
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Set up Python
uses: actions/setup-python@v5
- 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/uwsgi-nginx:${{ matrix.image.name }}
tiangolo/uwsgi-nginx:${{ 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@v4
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/uwsgi-nginx
32 changes: 19 additions & 13 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 @@ -32,30 +32,36 @@ jobs:
fail-fast: true
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- 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/uwsgi-nginx:${{ matrix.image.name }}
context: ./docker-images/
file: ./docker-images/${{ env.DOCKERFILE_NAME }}.dockerfile
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.7"
- name: Install poetry
run: |
python -m pip install --upgrade pip
python -m pip install poetry
- name: Configure poetry
run: python -m poetry config virtualenvs.create false
python-version: "3.10"
- name: Install Dependencies
run: python -m poetry install
run: python -m pip install docker pytest
- name: Test Image
run: python -m poetry run bash scripts/test.sh
run: bash scripts/test.sh
env:
NAME: ${{ matrix.image.name }}
DOCKERFILE: ${{ matrix.image.dockerfile }}
PYTHON_VERSION: ${{ matrix.image.python_version }}
SLEEP_TIME: "5"
check:
if: always()
needs:
- build
- test
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
Expand Down
21 changes: 0 additions & 21 deletions pyproject.toml

This file was deleted.

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