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

@ -35,19 +35,24 @@ jobs:
containerise: containerise:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v1 uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx - name: Set up Docker Buildx
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: Build and push - name: Lowercase github username for ghcr
uses: docker/build-push-action@v2 id: string
with: uses: ASzc/change-string-case-action@v1
platforms: linux/amd64 with:
push: true string: ${{ github.actor }}
tags: ghcr.io/meeb/${{ env.IMAGE_NAME }}:latest - name: Build and push
cache-from: type=registry,ref=ghcr.io/meeb/${{ env.IMAGE_NAME }}:latest uses: docker/build-push-action@v2
cache-to: type=inline with:
build-args: | platforms: linux/amd64,linux/arm64
IMAGE_NAME=${{ env.IMAGE_NAME }} push: true
tags: ghcr.io/${{ steps.string.outputs.lowercase }}/${{ env.IMAGE_NAME }}:latest
cache-from: type=registry,ref=ghcr.io/${{ steps.string.outputs.lowercase }}/${{ env.IMAGE_NAME }}:latest
cache-to: type=inline
build-args: |
IMAGE_NAME=${{ env.IMAGE_NAME }}

View File

@ -11,23 +11,28 @@ jobs:
containerise: containerise:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v1 uses: docker/setup-qemu-action@v1
- name: Get tag - name: Get tag
id: tag id: tag
uses: dawidd6/action-get-tag@v1 uses: dawidd6/action-get-tag@v1
- uses: docker/build-push-action@v2 - uses: docker/build-push-action@v2
- name: Set up Docker Buildx - name: Set up Docker Buildx
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: Build and push - name: Lowercase github username for ghcr
uses: docker/build-push-action@v2 id: string
with: uses: ASzc/change-string-case-action@v1
platforms: linux/amd64 with:
push: true string: ${{ github.actor }}
tags: ghcr.io/meeb/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }} - name: Build and push
cache-from: type=registry,ref=ghcr.io/meeb/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }} uses: docker/build-push-action@v2
cache-to: type=inline with:
build-args: | platforms: linux/amd64,linux/arm64
IMAGE_NAME=${{ env.IMAGE_NAME }} push: true
tags: ghcr.io/${{ steps.string.outputs.lowercase }}/${{ 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
build-args: |
IMAGE_NAME=${{ env.IMAGE_NAME }}

View File

@ -1,39 +1,52 @@
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" \
HOME="/root" \ HOME="/root" \
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 \
apt-get update && \ "linux/amd64") echo "amd64" ;; \
apt-get -y --no-install-recommends install locales && \ "linux/arm64") echo "aarch64" ;; \
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \ *) echo "" ;; esac) && \
locale-gen en_US.UTF-8 && \ export S6_EXPECTED_SHA256=$(case ${TARGETPLATFORM:-linux/amd64} in \
# Install required distro packages "linux/amd64") echo "a7076cf205b331e9f8479bbb09d9df77dbb5cd8f7d12e9b74920902e0c16dd98" ;; \
apt-get -y --no-install-recommends install curl ca-certificates binutils && \ "linux/arm64") echo "84f585a100b610124bb80e441ef2dc2d68ac2c345fd393d75a6293e0951ccfc5" ;; \
# Install s6 *) echo "" ;; esac) && \
curl -L ${S6_DOWNLOAD} --output /tmp/s6-overlay-${ARCH}.tar.gz && \ export S6_DOWNLOAD=$(case ${TARGETPLATFORM:-linux/amd64} in \
sha256sum /tmp/s6-overlay-${ARCH}.tar.gz && \ "linux/amd64") echo "https://github.com/just-containers/s6-overlay/releases/download/v${S6_VERSION}/s6-overlay-amd64.tar.gz" ;; \
echo "${S6_EXPECTED_SHA256} /tmp/s6-overlay-${ARCH}.tar.gz" | sha256sum -c - && \ "linux/arm64") echo "https://github.com/just-containers/s6-overlay/releases/download/v${S6_VERSION}/s6-overlay-aarch64.tar.gz" ;; \
tar xzf /tmp/s6-overlay-${ARCH}.tar.gz -C / && \ *) echo "" ;; esac) && \
# Clean up echo "Building for arch: ${ARCH}|${ARCH44}, downloading S6 from: ${S6_DOWNLOAD}}, expecting S6 SHA256: ${S6_EXPECTED_SHA256}" && \
rm -rf /tmp/s6-overlay-${ARCH}.tar.gz && \ set -x && \
apt-get -y autoremove --purge curl binutils apt-get update && \
apt-get -y --no-install-recommends install locales && \
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
locale-gen en_US.UTF-8 && \
# Install required distro packages
apt-get -y --no-install-recommends install curl ca-certificates binutils && \
# Install s6
curl -L ${S6_DOWNLOAD} --output /tmp/s6-overlay-${ARCH}.tar.gz && \
sha256sum /tmp/s6-overlay-${ARCH}.tar.gz && \
echo "${S6_EXPECTED_SHA256} /tmp/s6-overlay-${ARCH}.tar.gz" | sha256sum -c - && \
tar xzf /tmp/s6-overlay-${ARCH}.tar.gz -C / && \
# Clean up
rm -rf /tmp/s6-overlay-${ARCH}.tar.gz && \
apt-get -y autoremove --purge curl binutils
# Copy app # Copy app
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
@ -47,24 +60,25 @@ RUN set -x && \
# Install required distro packages # Install required distro packages
apt-get -y install nginx-light && \ apt-get -y install nginx-light && \
apt-get -y --no-install-recommends install \ apt-get -y --no-install-recommends install \
python3 \ python3 \
python3-setuptools \ python3-setuptools \
python3-pip \ python3-pip \
python3-dev \ python3-dev \
gcc \ gcc \
make \ g++ \
default-libmysqlclient-dev \ make \
libmariadb3 \ default-libmysqlclient-dev \
postgresql-common \ libmariadb3 \
libpq-dev \ postgresql-common \
libpq5 \ libpq-dev \
libjpeg62-turbo \ libpq5 \
libwebp6 \ libjpeg62-turbo \
libjpeg-dev \ libwebp6 \
zlib1g-dev \ libjpeg-dev \
libwebp-dev \ zlib1g-dev \
ffmpeg \ libwebp-dev \
redis-server && \ ffmpeg \
redis-server && \
# Install pipenv # Install pipenv
pip3 --disable-pip-version-check install wheel pipenv && \ pip3 --disable-pip-version-check install wheel pipenv && \
# Create a 'app' user which the application will run as # Create a 'app' user which the application will run as
@ -88,16 +102,17 @@ RUN set -x && \
pipenv --clear && \ pipenv --clear && \
pip3 --disable-pip-version-check uninstall -y pipenv wheel virtualenv && \ pip3 --disable-pip-version-check uninstall -y pipenv wheel virtualenv && \
apt-get -y autoremove --purge \ apt-get -y autoremove --purge \
python3-pip \ python3-pip \
python3-dev \ python3-dev \
gcc \ gcc \
make \ g++ \
default-libmysqlclient-dev \ make \
postgresql-common \ default-libmysqlclient-dev \
libpq-dev \ postgresql-common \
libjpeg-dev \ libpq-dev \
zlib1g-dev \ libjpeg-dev \
libwebp-dev && \ zlib1g-dev \
libwebp-dev && \
apt-get -y autoremove && \ apt-get -y autoremove && \
apt-get -y autoclean && \ apt-get -y autoclean && \
rm -rf /var/lib/apt/lists/* && \ rm -rf /var/lib/apt/lists/* && \

2
pip.conf Normal file
View File

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