Skip to content

Commit

Permalink
Dockerfile: Set to arm64v8 version
Browse files Browse the repository at this point in the history
Signed-off-by: Yang Deokgyu <secugyu@gmail.com>
  • Loading branch information
awesometic committed Jul 25, 2019
1 parent 1500a5a commit cd5f00d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Dockerfile
Expand Up @@ -18,7 +18,16 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.

FROM python:3.6.8-alpine3.9
# amd64 base image
FROM alpine:latest AS builder
LABEL maintainer="Yang Deokgyu <secugyu@gmail.com>" \
description="A Material for MkDocs port for arm64v8 platform."

# To set multiarch build for Docker hub automated build.
RUN apk add curl
RUN curl -L https://github.com/balena-io/qemu/releases/download/v3.0.0%2Bresin/qemu-3.0.0+resin-aarch64.tar.gz | tar zxvf - -C . && mv qemu-3.0.0+resin-aarch64/qemu-aarch64-static .
FROM arm64v8/python:3.6-alpine3.9
COPY --from=builder qemu-aarch64-static /usr/bin/

# Set build directory
WORKDIR /tmp
Expand Down
8 changes: 8 additions & 0 deletions hooks/build
@@ -0,0 +1,8 @@
#!/bin/bash

docker build \
--file "${DOCKERFILE_PATH}" \
--build-arg BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
--build-arg VCS_REF="$(git rev-parse --short HEAD)" \
--tag "$IMAGE_NAME" \
.
16 changes: 16 additions & 0 deletions hooks/post_checkout
@@ -0,0 +1,16 @@
#!/bin/bash

BUILD_ARCH=$(echo "${DOCKERFILE_PATH}" | cut -d '.' -f 2)

[ "${BUILD_ARCH}" == "Dockerfile" ] && \
{ echo 'qemu-user-static: Download not required for current arch'; exit 0; }

QEMU_USER_STATIC_ARCH=$([ "${BUILD_ARCH}" == "armhf" ] && echo "${BUILD_ARCH::-2}" || echo "${BUILD_ARCH}")
QEMU_USER_STATIC_DOWNLOAD_URL="https://github.com/multiarch/qemu-user-static/releases/download"
QEMU_USER_STATIC_LATEST_TAG=$(curl -s https://api.github.com/repos/multiarch/qemu-user-static/tags \
| grep 'name.*v[0-9]' \
| head -n 1 \
| cut -d '"' -f 4)

curl -SL "${QEMU_USER_STATIC_DOWNLOAD_URL}/${QEMU_USER_STATIC_LATEST_TAG}/x86_64_qemu-${QEMU_USER_STATIC_ARCH}-static.tar.gz" \
| tar xzv
8 changes: 8 additions & 0 deletions hooks/pre_build
@@ -0,0 +1,8 @@
#!/bin/bash

BUILD_ARCH=$(echo "${DOCKERFILE_PATH}" | cut -d '.' -f 2)

[ "${BUILD_ARCH}" == "Dockerfile" ] && \
{ echo 'qemu-user-static: Registration not required for current arch'; exit 0; }

docker run --rm --privileged multiarch/qemu-user-static:register --reset

1 comment on commit cd5f00d

@awesometic
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.