From c034514ecd7f311085e74cb82e6a068887e06386 Mon Sep 17 00:00:00 2001 From: Lens0021 Date: Sat, 17 Apr 2021 18:12:19 +0900 Subject: [PATCH] Add support for arm64 (#8) * Target multi-platform * Start from mysql/mysql-server image * Download aws-cli binary instead of pip --- .github/workflows/build.yaml | 4 ++++ Dockerfile | 20 +++++++++++--------- docker-cmd | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e78bae1..bf2d27a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -12,6 +12,9 @@ jobs: steps: # don't need to use the actions/checkout when using setup-buildx-action + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 @@ -31,6 +34,7 @@ jobs: uses: docker/build-push-action@v2 with: cache-from: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest + platforms: linux/amd64,linux/arm64 push: ${{ github.repository_owner == 'femiwiki' }} tags: | ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }} diff --git a/Dockerfile b/Dockerfile index 2f65039..9ca909c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ # # Build # -FROM mysql:8 +FROM --platform=$TARGETPLATFORM mysql/mysql-server:8.0.23 +ARG TARGETPLATFORM WORKDIR /a @@ -12,26 +13,27 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # Add Tini # See https://github.com/krallin/tini for the further details ENV TINI_VERSION v0.18.0 -ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini +RUN PLATFORM="$(echo $TARGETPLATFORM | cut -d/ -f2)" &&\ + curl -sLfo /tini "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${PLATFORM}" RUN chmod +x /tini ENTRYPOINT ["/tini", "--"] # Install cron -RUN apt-get update && apt-get -y install cron +RUN yum install -y cronie # Register a cronjob COPY crontab . RUN crontab crontab && rm crontab # Install php -RUN apt-get update && apt-get install -y php-cli - -# Install python -RUN apt-get update && apt-get install -y python3-pip +RUN yum install -y php-cli # Install AWS CLI -RUN python3 -m pip install --upgrade pip &&\ - python3 -m pip install awscli +RUN yum install -y unzip +RUN curl -sLfo awscli.zip "https://awscli.amazonaws.com/awscli-exe-linux-$(uname -p).zip" &&\ + unzip awscli.zip &&\ + ./aws/install &&\ + rm -rf awscli ./aws # Copy scripts COPY do-backup docker-cmd /usr/local/bin/ diff --git a/docker-cmd b/docker-cmd index 68c6264..d9b0f87 100755 --- a/docker-cmd +++ b/docker-cmd @@ -18,5 +18,5 @@ single-transaction EOF touch /tmp/log -cron +crond tail -f /tmp/log