Build docker image for aarch64

This commit is contained in:
SweetMNM 2022-06-07 19:04:34 +03:00
parent b4a247bf37
commit 97183fff97
2 changed files with 79 additions and 71 deletions

View File

@ -11,23 +11,23 @@ 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: 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/meeb/${{ 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/meeb/${{ 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,34 +1,42 @@
FROM debian:bullseye-slim FROM debian:bullseye-slim
ARG ARCH="amd64" ARG TARGETPLATFORM
ARG ARCH=$(case ${TARGETPLATFORM:-linux/amd64} in \
"linux/amd64") echo "amd64" ;; \
"linux/arm64") echo "aarch64" ;; \
*) echo "" ;; esac)
ARG S6_VERSION="2.2.0.3" ARG S6_VERSION="2.2.0.3"
RUN export ARCH=$(case ${TARGETPLATFORM:-linux/amd64} in \
"linux/amd64") echo "amd64" ;; \
"linux/arm64") echo "aarch64" ;; \
*) echo "" ;; esac) \
&& echo "ARCH=${ARCH}, ARCH2=$ARCH"
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_EXPECTED_SHA256="a7076cf205b331e9f8479bbb09d9df77dbb5cd8f7d12e9b74920902e0c16dd98" \
S6_DOWNLOAD="https://github.com/just-containers/s6-overlay/releases/download/v${S6_VERSION}/s6-overlay-${ARCH}.tar.gz" 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 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 && \
locale-gen en_US.UTF-8 && \ locale-gen en_US.UTF-8 && \
# Install required distro packages # Install required distro packages
apt-get -y --no-install-recommends install curl ca-certificates binutils && \ apt-get -y --no-install-recommends install curl ca-certificates binutils && \
# Install s6 # Install s6
curl -L ${S6_DOWNLOAD} --output /tmp/s6-overlay-${ARCH}.tar.gz && \ curl -L ${S6_DOWNLOAD} --output /tmp/s6-overlay-${ARCH}.tar.gz && \
sha256sum /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 - && \ echo "${S6_EXPECTED_SHA256} /tmp/s6-overlay-${ARCH}.tar.gz" | sha256sum -c - && \
tar xzf /tmp/s6-overlay-${ARCH}.tar.gz -C / && \ tar xzf /tmp/s6-overlay-${ARCH}.tar.gz -C / && \
# Clean up # Clean up
rm -rf /tmp/s6-overlay-${ARCH}.tar.gz && \ rm -rf /tmp/s6-overlay-${ARCH}.tar.gz && \
apt-get -y autoremove --purge curl binutils apt-get -y autoremove --purge curl binutils
# Copy app # Copy app
COPY tubesync /app COPY tubesync /app
@ -47,24 +55,24 @@ 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 \ make \
default-libmysqlclient-dev \ default-libmysqlclient-dev \
libmariadb3 \ libmariadb3 \
postgresql-common \ postgresql-common \
libpq-dev \ libpq-dev \
libpq5 \ libpq5 \
libjpeg62-turbo \ libjpeg62-turbo \
libwebp6 \ libwebp6 \
libjpeg-dev \ libjpeg-dev \
zlib1g-dev \ zlib1g-dev \
libwebp-dev \ libwebp-dev \
ffmpeg \ ffmpeg \
redis-server && \ 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 +96,16 @@ 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 \ make \
default-libmysqlclient-dev \ default-libmysqlclient-dev \
postgresql-common \ postgresql-common \
libpq-dev \ libpq-dev \
libjpeg-dev \ libjpeg-dev \
zlib1g-dev \ zlib1g-dev \
libwebp-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/* && \