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

Build containers for multiple architectures #93

Closed
wants to merge 7 commits into from
Closed
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
5 changes: 5 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ jobs:
uses: actions/setup-python@v1
with:
python-version: "3.7"
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Install Dependencies
run: python3.7 -m pip install docker pytest
- name: Deploy Image
Expand Down
9 changes: 7 additions & 2 deletions docker-images/python3.8-slim.dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
FROM python:3.8

COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt


FROM python:3.8-slim

LABEL maintainer="Sebastian Ramirez <tiangolo@gmail.com>"

COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt
COPY --from=0 /usr/local/lib/python3.8 /usr/local/lib/python3.8

COPY ./start.sh /start.sh
RUN chmod +x /start.sh
Expand Down
9 changes: 7 additions & 2 deletions docker-images/python3.9-slim.dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
FROM python:3.9

COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt


FROM python:3.9-slim

LABEL maintainer="Sebastian Ramirez <tiangolo@gmail.com>"

COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt
COPY --from=0 /usr/local/lib/python3.9 /usr/local/lib/python3.9

COPY ./start.sh /start.sh
RUN chmod +x /start.sh
Expand Down
21 changes: 15 additions & 6 deletions scripts/build-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@

set -e

use_tag="tiangolo/uvicorn-gunicorn:$NAME"
use_dated_tag="${use_tag}-$(date -I)"
DOCKERFILE="$NAME"

bash scripts/build.sh
if [ "$NAME" == "latest" ] ; then
DOCKERFILE="python3.9"
fi

docker tag "$use_tag" "$use_dated_tag"
use_tag="tiangolo/uvicorn-gunicorn:$NAME"
use_dated_tag="${use_tag}-$(date -I)"

bash scripts/docker-login.sh

docker push "$use_tag"
docker push "$use_dated_tag"
docker buildx use multiarch || docker buildx create --name multiarch --use

docker buildx build \
--platform "linux/amd64,linux/arm64,linux/arm/v7" \
--file "./docker-images/${DOCKERFILE}.dockerfile" \
-t "$use_tag" \
-t "$use_dated_tag" \
--push \
"./docker-images/"