Skip to content

Commit

Permalink
Try to split image build using cross-compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
Hartorn committed Sep 12, 2023
1 parent 72c290f commit 933f21a
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 35 deletions.
103 changes: 73 additions & 30 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,43 @@ on:
# - cron: '0 5 * * *'
workflow_dispatch:

# https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners

jobs:
build-images:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # Do not stop when any job fails
matrix:
os: [ubuntu-latest]
platform: ['linux/amd64']
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
include:
- os: windows-2022
platform: windows/amd64
- os: ubuntu-latest
platform: linux/arm64

steps:
- name: Checkout code
uses: actions/[email protected]
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Set up Docker Buildx
id: builder
uses: docker/setup-buildx-action@master
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
if: ${{ matrix.platform == 'linux/arm64' }}

- name: "Append ARM buildx builder from Oracle cloud"
uses: baschny/append-buildx-action@v1
with:
builder: ${{ steps.builder.outputs.name }}
endpoint: ssh://${{ secrets.ARM_SSH_CONNECTION_STRING }}
ssh_private_key: ${{ secrets.ARM_SSH_PRIVATE_KEY }}
# - name: Set up Docker Buildx
# id: builder
# uses: docker/setup-buildx-action@v3

# - name: "Append ARM buildx builder from Oracle cloud"
# uses: baschny/append-buildx-action@v1
# with:
# builder: ${{ steps.builder.outputs.name }}
# endpoint: ssh://${{ secrets.ARM_SSH_CONNECTION_STRING }}
# ssh_private_key: ${{ secrets.ARM_SSH_PRIVATE_KEY }}

- name: Extract branch name
shell: bash
Expand All @@ -36,24 +56,47 @@ jobs:
echo "tag=$SANITIZED_BRANCH" >> $GITHUB_OUTPUT
id: extract_branch

- name: Login to Docker registry
uses: docker/login-action@v2
# - name: Login to Docker registry
# uses: docker/login-action@v3
# with:
# username: giskardai
# password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
username: giskardai
password: ${{ secrets.DOCKERHUB_TOKEN }}
# context: "{{defaultContext}}"
context: .
push: false #true
tags: giskardai/giskard:${{ steps.extract_branch.outputs.tag }}
platforms: ${{ matrix.platform }}

- name: Build and push image based on the current branch
env:
IMAGE: docker.io/giskardai/giskard
run: |
docker buildx build \
--platform linux/amd64,linux/arm64 \
--tag $IMAGE:${{ steps.extract_branch.outputs.tag }} \
--file Dockerfile \
--push \
.
- name: Invoke deployment hook
if: ${{ steps.extract_branch.outputs.branch == 'main' }}
run: |
curl -L --silent --max-time 900 ${{ secrets.TEST_SERVER_WEBHOOK_URL_BASE }}/redeploy-dev
# - uses: mr-smithers-excellent/docker-build-push@v6
# name: Build & push Docker image
# with:
# image: giskardai/giskard
# tags: ${{ steps.extract_branch.outputs.tag }}
# registry: docker.io
# dockerfile: Dockerfile
# enableBuildKit: true
# platform: ${{ matrix.platform }}
# multiPlatform: true
# pushImage: false
# # username: ${{ secrets.DOCKER_USERNAME }}
# # password: ${{ secrets.DOCKER_PASSWORD }}

# - name: Build and push image based on the current branch
# env:
# IMAGE: docker.io/giskardai/giskard
# run: |
# docker buildx build \
# --platform linux/amd64,linux/arm64 \
# --tag $IMAGE:${{ steps.extract_branch.outputs.tag }} \
# --file Dockerfile \
# --push \
# .

# - name: Invoke deployment hook
# if: ${{ steps.extract_branch.outputs.branch == 'main' }}
# run: |
# curl -L --silent --max-time 900 ${{ secrets.TEST_SERVER_WEBHOOK_URL_BASE }}/redeploy-dev
6 changes: 3 additions & 3 deletions .github/workflows/build_backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-depth: 1
- name: Extract branch name
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
id: extract_branch
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-depth: 1

- name: Set up JDK 17
uses: actions/setup-java@v3
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-depth: 1

- name: Set up JDK 17
uses: actions/setup-java@v3
Expand Down
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,18 @@ COPY gradle gradle
COPY .git .git

COPY build.gradle.kts gradle.properties gradlew settings.gradle.kts ./
# Install PDM
RUN curl -sSL https://pdm.fming.dev/install-pdm.py | python3 -

RUN ./gradlew clean install -Pprod --parallel --info --stacktrace
WORKDIR /app/python-client
RUN pdm run clean
RUN pdm run install --prod
RUN pdm run test
RUN pdm run build

WORKDIR /app
RUN ./gradlew :backend:package -Pprod --parallel --info --stacktrace
RUN ./gradlew :frontend:package -Pprod --parallel --info --stacktrace
RUN ./gradlew :python-client:package -Pprod --parallel --info --stacktrace


# Create an environment and install giskard wheel. Some dependencies may require gcc which is only installed in build
Expand Down

0 comments on commit 933f21a

Please sign in to comment.