Merge pull request #246 from SweetMNM/main

Build docker image for amd64 and arm64
This commit is contained in:
meeb 2022-06-08 23:37:49 +10:00 committed by GitHub
commit 95e727b0a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 115 additions and 88 deletions

View File

@ -41,13 +41,18 @@ jobs:
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
- name: Log into GitHub Container Registry - name: Log into GitHub Container Registry
run: echo "${{ secrets.REGISTRY_ACCESS_TOKEN }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin run: echo "${{ secrets.REGISTRY_ACCESS_TOKEN }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin
- name: Lowercase github username for ghcr
id: string
uses: ASzc/change-string-case-action@v1
with:
string: ${{ github.actor }}
- name: Build and push - name: Build and push
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
platforms: linux/amd64 platforms: linux/amd64,linux/arm64
push: true push: true
tags: ghcr.io/meeb/${{ env.IMAGE_NAME }}:latest tags: ghcr.io/${{ steps.string.outputs.lowercase }}/${{ env.IMAGE_NAME }}:latest
cache-from: type=registry,ref=ghcr.io/meeb/${{ env.IMAGE_NAME }}:latest cache-from: type=registry,ref=ghcr.io/${{ steps.string.outputs.lowercase }}/${{ env.IMAGE_NAME }}:latest
cache-to: type=inline cache-to: type=inline
build-args: | build-args: |
IMAGE_NAME=${{ env.IMAGE_NAME }} IMAGE_NAME=${{ env.IMAGE_NAME }}

View File

@ -21,13 +21,18 @@ jobs:
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
- name: Log into GitHub Container Registry - name: Log into GitHub Container Registry
run: echo "${{ secrets.REGISTRY_ACCESS_TOKEN }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin run: echo "${{ secrets.REGISTRY_ACCESS_TOKEN }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin
- name: Lowercase github username for ghcr
id: string
uses: ASzc/change-string-case-action@v1
with:
string: ${{ github.actor }}
- name: Build and push - name: Build and push
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
platforms: linux/amd64 platforms: linux/amd64,linux/arm64
push: true push: true
tags: ghcr.io/meeb/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }} tags: ghcr.io/${{ steps.string.outputs.lowercase }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }}
cache-from: type=registry,ref=ghcr.io/meeb/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }} cache-from: type=registry,ref=ghcr.io/${{ steps.string.outputs.lowercase }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }}
cache-to: type=inline cache-to: type=inline
build-args: | build-args: |
IMAGE_NAME=${{ env.IMAGE_NAME }} IMAGE_NAME=${{ env.IMAGE_NAME }}

View File

@ -1,6 +1,6 @@
FROM debian:bullseye-slim FROM debian:bullseye-slim
ARG ARCH="amd64" ARG TARGETPLATFORM
ARG S6_VERSION="2.2.0.3" ARG S6_VERSION="2.2.0.3"
ENV DEBIAN_FRONTEND="noninteractive" \ ENV DEBIAN_FRONTEND="noninteractive" \
@ -8,13 +8,23 @@ ENV DEBIAN_FRONTEND="noninteractive" \
LANGUAGE="en_US.UTF-8" \ LANGUAGE="en_US.UTF-8" \
LANG="en_US.UTF-8" \ LANG="en_US.UTF-8" \
LC_ALL="en_US.UTF-8" \ LC_ALL="en_US.UTF-8" \
TERM="xterm" \ TERM="xterm"
S6_EXPECTED_SHA256="a7076cf205b331e9f8479bbb09d9df77dbb5cd8f7d12e9b74920902e0c16dd98" \
S6_DOWNLOAD="https://github.com/just-containers/s6-overlay/releases/download/v${S6_VERSION}/s6-overlay-${ARCH}.tar.gz"
# Install third party software # Install third party software
RUN set -x && \ RUN export ARCH=$(case ${TARGETPLATFORM:-linux/amd64} in \
"linux/amd64") echo "amd64" ;; \
"linux/arm64") echo "aarch64" ;; \
*) echo "" ;; esac) && \
export S6_EXPECTED_SHA256=$(case ${TARGETPLATFORM:-linux/amd64} in \
"linux/amd64") echo "a7076cf205b331e9f8479bbb09d9df77dbb5cd8f7d12e9b74920902e0c16dd98" ;; \
"linux/arm64") echo "84f585a100b610124bb80e441ef2dc2d68ac2c345fd393d75a6293e0951ccfc5" ;; \
*) echo "" ;; esac) && \
export S6_DOWNLOAD=$(case ${TARGETPLATFORM:-linux/amd64} in \
"linux/amd64") echo "https://github.com/just-containers/s6-overlay/releases/download/v${S6_VERSION}/s6-overlay-amd64.tar.gz" ;; \
"linux/arm64") echo "https://github.com/just-containers/s6-overlay/releases/download/v${S6_VERSION}/s6-overlay-aarch64.tar.gz" ;; \
*) echo "" ;; esac) && \
echo "Building for arch: ${ARCH}|${ARCH44}, downloading S6 from: ${S6_DOWNLOAD}}, expecting S6 SHA256: ${S6_EXPECTED_SHA256}" && \
set -x && \
apt-get update && \ apt-get update && \
apt-get -y --no-install-recommends install locales && \ apt-get -y --no-install-recommends install locales && \
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \ echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
@ -34,6 +44,9 @@ RUN set -x && \
COPY tubesync /app COPY tubesync /app
COPY tubesync/tubesync/local_settings.py.container /app/tubesync/local_settings.py COPY tubesync/tubesync/local_settings.py.container /app/tubesync/local_settings.py
# Copy over pip.conf to use piwheels
COPY pip.conf /etc/pip.conf
# Add Pipfile # Add Pipfile
COPY Pipfile /app/Pipfile COPY Pipfile /app/Pipfile
COPY Pipfile.lock /app/Pipfile.lock COPY Pipfile.lock /app/Pipfile.lock
@ -52,6 +65,7 @@ RUN set -x && \
python3-pip \ python3-pip \
python3-dev \ python3-dev \
gcc \ gcc \
g++ \
make \ make \
default-libmysqlclient-dev \ default-libmysqlclient-dev \
libmariadb3 \ libmariadb3 \
@ -91,6 +105,7 @@ RUN set -x && \
python3-pip \ python3-pip \
python3-dev \ python3-dev \
gcc \ gcc \
g++ \
make \ make \
default-libmysqlclient-dev \ default-libmysqlclient-dev \
postgresql-common \ postgresql-common \

2
pip.conf Normal file
View File

@ -0,0 +1,2 @@
[global]
extra-index-url=https://www.piwheels.org/simple