Skip to content

Commit

Permalink
Isolate docker build images
Browse files Browse the repository at this point in the history
  • Loading branch information
c0rv4x committed Oct 18, 2024
1 parent 18f2845 commit 7b34702
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
- name: bazel version
run: bazel version
- name: Build docker image
run: bazel build --sandbox_writable_path=$HOME //docker:orchestration_image_tar
run: bazel build --sandbox_writable_path=$HOME //docker:orchestration_image_tar --action_env=PLATFORM=linux/amd64
- name: Set filename of docker image
run: mv bazel-bin/docker/orchestration-image.tar ${{ env.x86_64_image_path }}
- name: Publish docker image
Expand All @@ -76,11 +76,14 @@ jobs:
export-docker-image-arm64:
runs-on: arm-ubuntu-arm-22.04-4core
container:
image: arm64v8/ubuntu:22.04 # Specify an arm64 Docker image here
options: --security-opt=no-new-privileges # Optional: Add additional Docker security options
image: arm64v8/ubuntu:22.04
options: --security-opt=no-new-privileges
steps:
- name: Checkout repository
uses: actions/checkout@a81bbbf8298c0fa03ea29cdc473d45769f953675 # aka v2
- name: Install sudo
run: |
apt-get update && apt-get install -y sudo
- name: Get docker image name
run: |
short_sha=$(echo ${{ github.sha }} | cut -c1-8)
Expand All @@ -90,7 +93,7 @@ jobs:
- name: bazel version
run: bazel version
- name: Build docker image
run: bazel build --sandbox_writable_path=$HOME //docker:orchestration_image_tar
run: bazel build --sandbox_writable_path=$HOME //docker:orchestration_image_tar --action_env=PLATFORM=linux/arm64
- name: Set filename of docker image
run: mv bazel-bin/docker/orchestration-image.tar ${{ env.arm64_image_path }}
- name: Publish docker image
Expand Down
32 changes: 20 additions & 12 deletions docker/image-builder.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
#!/usr/bin/env bash

# This shell script exists for building docker image.
# Docker image includes HO(Host Orchestrator) inside,
# so it could execute CF instance with API in HO.
# This shell script exists for building Docker image using Docker Buildx.
# The image includes HO (Host Orchestrator) inside, so it can execute CF instance with API in HO.

script_location=`realpath -s $(dirname ${BASH_SOURCE[0]})`
android_cuttlefish_root_dir=$(realpath -s $script_location/..)
set -e

script_location=$(realpath -s $(dirname "${BASH_SOURCE[0]}"))
android_cuttlefish_root_dir=$(realpath -s "$script_location/..")

if [[ "$1" == "" ]]; then
tag=cuttlefish-orchestration
tag="cuttlefish-orchestration"
else
tag=$1
tag="$1"
fi

# Build docker image
pushd $android_cuttlefish_root_dir
docker build \
# Use the PLATFORM environment variable, defaulting to linux/amd64 if not set
platforms="${PLATFORM:-linux/amd64}"

# Set up Docker Buildx if not already set up
docker buildx create --use || true

# Build the Docker image using Buildx for x86_64 and arm64 platforms
pushd "$android_cuttlefish_root_dir"
docker buildx build \
--platform "$platforms" \
--force-rm \
--no-cache \
-f docker/Dockerfile \
-t $tag \
.
-t "$tag" \
--load .
popd

0 comments on commit 7b34702

Please sign in to comment.