Skip to content

Commit

Permalink
Sandbox support for arm64 (flyteorg#1742)
Browse files Browse the repository at this point in the history
* fix: add arch agnostic installs

Signed-off-by: avan-sh <[email protected]>

* feat: arm64 build using docker build action

Signed-off-by: avan-sh <[email protected]>

* fix: revert to original repo

Signed-off-by: avan-sh <[email protected]>

* fix: conditional ghcr login

Signed-off-by: avan-sh <[email protected]>

* fix: invert condition

Signed-off-by: avan-sh <[email protected]>
  • Loading branch information
avan-sh authored Nov 1, 2021
1 parent e65cb1e commit 157d56e
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 36 deletions.
96 changes: 66 additions & 30 deletions .github/workflows/sandbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,78 @@ on:
types: [published]

jobs:
push-sandbox-image:
name: Push sandbox image to GHCR
sandbox-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: "0"
- name: Push Sandbox Docker Image to Github Registry
uses: whoan/docker-build-with-cache-action@v5
- name: Prepare sandbox Image Names
id: sandbox-names
uses: docker/metadata-action@v3
with:
# https://docs.github.com/en/packages/learn-github-packages/publishing-a-package
username: "${{ secrets.FLYTE_BOT_USERNAME }}"
password: "${{ secrets.FLYTE_BOT_PAT }}"
image_name: ${{ github.repository_owner }}/flyte-sandbox
image_tag: latest,${{ github.sha }},${{ github.event.ref }}
registry: ghcr.io
build_extra_args: "--target=default --compress=true"
context: ./
dockerfile: docker/sandbox/Dockerfile
push_image_and_stages: ${{ github.event_name == 'release' }}
push-sandbox-dind-image:
name: Push sandbox DinD image to GHCR
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# list of Docker images to use as base name for tags
images: |
ghcr.io/${{ github.repository_owner }}/flyte-sandbox
tags: |
latest
type=sha,format=long
- name: Prepare DIND Image Names
id: dind-names
uses: docker/metadata-action@v3
with:
fetch-depth: "0"
- name: Push Sandbox DinD Docker Image to Github Registry
uses: whoan/docker-build-with-cache-action@v5
# list of Docker images to use as base name for tags
images: |
ghcr.io/${{ github.repository_owner }}/flyte-sandbox
tags: |
dind
type=sha,format=long, prefix=dind-
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-single-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-single-buildx
- name: Login to GitHub Container Registry
if: ${{ github.event_name == 'release' }}
uses: docker/login-action@v1
with:
registry: ghcr.io
username: "${{ secrets.FLYTE_BOT_USERNAME }}"
password: "${{ secrets.FLYTE_BOT_PAT }}"
image_name: ${{ github.repository_owner }}/flyte-sandbox
image_tag: dind,dind-${{ github.sha }},dind-${{ github.event.ref }}
registry: ghcr.io
build_extra_args: "--target=dind --compress=true"
context: ./
dockerfile: docker/sandbox/Dockerfile
push_image_and_stages: ${{ github.event_name == 'release' }}
- name: Build and push Sandbox image
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/arm64, linux/amd64
push: ${{ github.event_name == 'release' }}
target: default
tags: ${{ steps.sandbox-names.outputs.tags }}
file: docker/sandbox/Dockerfile
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
- name: Build and push DIND Image
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/arm64, linux/amd64
push: ${{ github.event_name == 'release' }}
target: dind
tags: ${{ steps.dind-names.outputs.tags }}
file: docker/sandbox/Dockerfile
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
- # Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
25 changes: 19 additions & 6 deletions docker/sandbox/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,34 @@ RUN git clone -b ${BUILDKIT_CLI_FOR_KUBECTL_VERSION} --single-branch --depth 1 h

FROM alpine:3.13.5 AS base_

# Install dependencies
RUN apk add --no-cache openssl

# Make directory to store artifacts
RUN mkdir -p /flyteorg/bin /flyteorg/share

# Install k3s
ARG K3S_VERSION="v1.21.1%2Bk3s1"
RUN wget -q -O /flyteorg/bin/k3s https://github.com/k3s-io/k3s/releases/download/${K3S_VERSION}/k3s \
ARG TARGETARCH

RUN case $TARGETARCH in \
amd64) export SUFFIX=;; \
arm64) export SUFFIX=-arm64;; \
aarch64) export SUFFIX=-arm64;; \
# TODO: Check if we need to add case fail
esac; \
wget -q -O /flyteorg/bin/k3s https://github.com/k3s-io/k3s/releases/download/${K3S_VERSION}/k3s${SUFFIX} \
&& chmod +x /flyteorg/bin/k3s

# Install Helm
ENV HELM_URL="https://get.helm.sh"
ARG HELM_VERSION="v3.6.3"
RUN wget ${HELM_URL}/helm-${HELM_VERSION}-linux-amd64.tar.gz -O - | tar -xz && \
mv linux-amd64/helm /flyteorg/bin/helm && \
chmod +x /flyteorg/bin/helm && \
rm -rf linux-amd64

RUN wget -q -O /flyteorg/bin/get_helm.sh https://raw.githubusercontent.com/helm/helm/${HELM_VERSION}/scripts/get-helm-3 && \
chmod 700 /flyteorg/bin/get_helm.sh && \
sh /flyteorg/bin/get_helm.sh --version ${HELM_VERSION} && \
mv /usr/local/bin/helm /flyteorg/bin/helm && \
rm /flyteorg/bin/get_helm.sh


# Install flytectl
RUN wget -q -O - https://raw.githubusercontent.com/flyteorg/flytectl/master/install.sh | BINDIR=/flyteorg/bin sh -s
Expand Down

0 comments on commit 157d56e

Please sign in to comment.