Skip to content

Commit

Permalink
build: support arm64 via multi arch builds of engine/apic/files-artif…
Browse files Browse the repository at this point in the history
…acts-expander (#1340)

## Description:
We bundled the amd64 binary onto a fake arm64 image

The image is now real arm64 as of #1317
This fixes the binary part

## Is this change user facing?
YES

Needs no docs though as we now will truly support arm64
  • Loading branch information
h4ck3rk3y committed Sep 19, 2023
1 parent e745c47 commit 022116a
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 6 deletions.
12 changes: 12 additions & 0 deletions .circleci/config.yml
Expand Up @@ -942,6 +942,10 @@ jobs:
- run: |
skip_docker_image_building=true
core/files_artifacts_expander/scripts/build.sh "${skip_docker_image_building}"
- run: |
skip_docker_image_building=true
build_architecture=arm64
core/files_artifacts_expander/scripts/build.sh "${skip_docker_image_building}" "${build_architecture}"
- run: |
set -euo pipefail
source core/files_artifacts_expander/scripts/_constants.env
Expand Down Expand Up @@ -980,6 +984,10 @@ jobs:
- run: |
skip_docker_image_building=true
core/server/scripts/build.sh "${skip_docker_image_building}"
- run: |
skip_docker_image_building=true
build_architecture=arm64
core/server/scripts/build.sh "${skip_docker_image_building}" "${build_architecture}"
- run: |
set -euo pipefail
source core/server/scripts/_constants.env
Expand Down Expand Up @@ -1019,6 +1027,10 @@ jobs:
- run: |
skip_docker_image_building=true
engine/server/scripts/build.sh "${skip_docker_image_building}"
- run: |
skip_docker_image_building=true
build_architecture=arm64
engine/server/scripts/build.sh "${skip_docker_image_building}" "${build_architecture}"
- run: |
set -euo pipefail
source engine/server/scripts/_constants.env
Expand Down
4 changes: 3 additions & 1 deletion core/files_artifacts_expander/Dockerfile
Expand Up @@ -2,8 +2,10 @@ FROM alpine:3.17

RUN apk update && apk add tar

ARG TARGETARCH

WORKDIR /run

COPY ./build/files-artifacts-expander ./
COPY ./build/files-artifacts-expander.$TARGETARCH ./files-artifacts-expander

CMD ./files-artifacts-expander
8 changes: 7 additions & 1 deletion core/files_artifacts_expander/scripts/build.sh
Expand Up @@ -15,6 +15,7 @@ source "${script_dirpath}/_constants.env"
BUILD_DIRNAME="build"

DEFAULT_SKIP_DOCKER_IMAGE_BUILDING=false
DEFAULT_ARCHITECTURE_TO_BUILD=amd64

MAIN_GO_FILEPATH="${expander_root_dirpath}/main.go"
MAIN_BINARY_OUTPUT_FILENAME="files-artifacts-expander"
Expand All @@ -28,6 +29,11 @@ if [ "${skip_docker_image_building}" != "true" ] && [ "${skip_docker_image_build
echo "Error: Invalid skip-docker-image-building arg '${skip_docker_image_building}'" >&2
fi

architecture_to_build="${2:-"${DEFAULT_ARCHITECTURE_TO_BUILD}"}"
if [ "${architecture_to_build}" != "amd64" ] && [ "${architecture_to_build}" != "arm64" ]; then
echo "Error: Invalid architecture-to-build arg '${architecture_to_build}'" >&2
fi

# Checks if dockerignore file is in the root path
if ! [ -f "${expander_root_dirpath}"/.dockerignore ]; then
echo "Error: No .dockerignore file found in files artifacts expander root '${expander_root_dirpath}'; this is required so Docker caching is enabled and the image builds remain quick" >&2
Expand All @@ -48,7 +54,7 @@ echo "Tests succeeded"

# Build binary for packaging inside an Alpine Linux image
echo "Building files artifacts expander main.go '${MAIN_GO_FILEPATH}'..."
if ! CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "${MAIN_BINARY_OUTPUT_FILEPATH}" "${MAIN_GO_FILEPATH}"; then
if ! CGO_ENABLED=0 GOOS=linux GOARCH=${architecture_to_build} go build -o "${MAIN_BINARY_OUTPUT_FILEPATH}.${architecture_to_build}" "${MAIN_GO_FILEPATH}"; then
echo "Error: An error occurred building the files artifacts expander code" >&2
exit 1
fi
Expand Down
4 changes: 3 additions & 1 deletion core/server/Dockerfile
Expand Up @@ -3,8 +3,10 @@ FROM alpine:3.17
# We need protobut-dev to run protobuf compiler against startosis .proto files
RUN apk update && apk add --no-cache bash protobuf-dev

ARG TARGETARCH

WORKDIR /run

COPY ./build/api-container ./
COPY ./build/api-container.$TARGETARCH ./api-container

CMD ./api-container
8 changes: 7 additions & 1 deletion core/server/scripts/build.sh
Expand Up @@ -13,6 +13,7 @@ source "${script_dirpath}/_constants.env"
BUILD_DIRNAME="build"

DEFAULT_SKIP_DOCKER_IMAGE_BUILDING=false
DEFAULT_ARCHITECTURE_TO_BUILD=amd64

MAIN_DIRNAME="api_container"
MAIN_GO_FILEPATH="${server_root_dirpath}/${MAIN_DIRNAME}/main.go"
Expand All @@ -27,6 +28,11 @@ if [ "${skip_docker_image_building}" != "true" ] && [ "${skip_docker_image_build
echo "Error: Invalid skip-docker-image-building arg '${skip_docker_image_building}'" >&2
fi

architecture_to_build="${2:-"${DEFAULT_ARCHITECTURE_TO_BUILD}"}"
if [ "${architecture_to_build}" != "amd64" ] && [ "${architecture_to_build}" != "arm64" ]; then
echo "Error: Invalid architecture-to-build arg '${architecture_to_build}'" >&2
fi

# Checks if dockerignore file is in the root path
if ! [ -f "${server_root_dirpath}"/.dockerignore ]; then
echo "Error: No .dockerignore file found in server root '${server_root_dirpath}'; this is required so Docker caching is enabled and the image builds remain quick" >&2
Expand All @@ -47,7 +53,7 @@ echo "Tests succeeded"

# Build binary for packaging inside an Alpine Linux image
echo "Building server main.go '${MAIN_GO_FILEPATH}'..."
if ! CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "${MAIN_BINARY_OUTPUT_FILEPATH}" "${MAIN_GO_FILEPATH}"; then
if ! CGO_ENABLED=0 GOOS=linux GOARCH=${architecture_to_build} go build -o "${MAIN_BINARY_OUTPUT_FILEPATH}.${architecture_to_build}" "${MAIN_GO_FILEPATH}"; then
echo "Error: An error occurred building the server code" >&2
exit 1
fi
Expand Down
4 changes: 3 additions & 1 deletion engine/server/Dockerfile
Expand Up @@ -2,10 +2,12 @@ FROM alpine:3.17

RUN apk update && apk add bash

ARG TARGETARCH

WORKDIR /run

ADD ./webapp ./webapp

COPY ./build/kurtosis-engine ./
COPY ./build/kurtosis-engine.$TARGETARCH ./kurtosis-engine

CMD ./kurtosis-engine
8 changes: 7 additions & 1 deletion engine/server/scripts/build.sh
Expand Up @@ -14,6 +14,7 @@ source "${script_dirpath}/_constants.env"
BUILD_DIRNAME="build"

DEFAULT_SKIP_DOCKER_IMAGE_BUILDING=false
DEFAULT_ARCHITECTURE_TO_BUILD=amd64

MAIN_DIRNAME="engine"
MAIN_GO_FILEPATH="${engine_root_dirpath}/${MAIN_DIRNAME}/main.go"
Expand All @@ -28,6 +29,11 @@ if [ "${skip_docker_image_building}" != "true" ] && [ "${skip_docker_image_build
echo "Error: Invalid skip-docker-image-building arg '${skip_docker_image_building}'" >&2
fi

architecture_to_build="${2:-"${DEFAULT_ARCHITECTURE_TO_BUILD}"}"
if [ "${architecture_to_build}" != "amd64" ] && [ "${architecture_to_build}" != "arm64" ]; then
echo "Error: Invalid architecture-to-build arg '${architecture_to_build}'" >&2
fi

# Checks if dockerignore file is in the root path
if ! [ -f "${engine_root_dirpath}"/.dockerignore ]; then
echo "Error: No .dockerignore file found in server root '${engine_root_dirpath}'; this is required so Docker caching is enabled and the image builds remain quick" >&2
Expand All @@ -48,7 +54,7 @@ echo "Tests succeeded"

# Build binary for packaging inside an Alpine Linux image
echo "Building server main.go '${MAIN_GO_FILEPATH}'..."
if ! CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "${MAIN_BINARY_OUTPUT_FILEPATH}" "${MAIN_GO_FILEPATH}"; then
if ! CGO_ENABLED=0 GOOS=linux GOARCH=${architecture_to_build} go build -o "${MAIN_BINARY_OUTPUT_FILEPATH}.${architecture_to_build}" "${MAIN_GO_FILEPATH}"; then
echo "Error: An error occurred building the server code" >&2
exit 1
fi
Expand Down

0 comments on commit 022116a

Please sign in to comment.