Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ubuntu/image: Upload as artefact in PRs #281

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions .github/workflows/_build_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ on:
test_toolchain:
type: boolean
default: false
upload_ubuntu_image:
type: boolean
default: false

host_platform:
type: string
Expand All @@ -51,6 +54,10 @@ jobs:
if: ${{ inputs.os_family != 'windows' }}
- name: 'Checkout repository'
uses: actions/checkout@v3
- uses: envoyproxy/toolshed/gh-actions/docker/[email protected]
if: ${{ inputs.os_family != 'windows' }}
# (inputs.test_toolchain || inputs.upload_ubuntu_image) &&
name: 'Start Docker registry'
- run: |
CONTAINER_TAG=$(git log -1 --pretty=format:"%H" "./docker")
echo "tag=${CONTAINER_TAG}" >> "$GITHUB_OUTPUT"
Expand All @@ -71,6 +78,7 @@ jobs:
if [[ "${{inputs.os_family }}" == "windows" ]]; then
export PATH="${PROGRAMFILES}/google-cloud-sdk/bin:${PATH}"
fi
docker ps -a
cd docker
./push.sh
name: Build (${{ inputs.image_prefix }}${{ inputs.distro }}@${{ steps.container.outputs.tag }})
Expand All @@ -92,11 +100,6 @@ jobs:
with:
go-version: ${{ inputs.go_version }}
cache: false
- uses: envoyproxy/toolshed/gh-actions/docker/[email protected]
if: ${{ inputs.test_toolchain && inputs.os_family != 'windows' }}
name: 'Start and load Docker registry'
with:
load: envoyproxy/envoy-build-ubuntu:${{ steps.container.outputs.tag }}
- uses: envoyproxy/toolshed/gh-actions/docker/[email protected]
if: ${{ inputs.test_toolchain && inputs.os_family == 'windows' }}
name: 'Start and load Docker registry (Windows)'
Expand All @@ -112,3 +115,15 @@ jobs:
SOURCE_BRANCH: ${{ github.ref }}
NO_PULL_IMAGE: true
DOCKER_IMAGE: localhost:5000/envoy-build-${{ inputs.distro }}
- run: |
sudo mkdir -p /mnt/cache
sudo mount -t tmpfs none /mnt/cache
docker save envoyproxy/envoy-build-ubuntu:${{ steps.container.outputs.tag }}-multi \
| zstd - -q -T0 -o /mnt/cache/envoy-build-ubuntu-${{ steps.container.outputs.tag }}.tar.zst
if: ${{ inputs.upload_ubuntu_image }}
shell: bash
- uses: actions/upload-artifact@v3
if: ${{ inputs.upload_ubuntu_image }}
with:
name: envoy-build-ubuntu-${{ steps.container.outputs.tag }}
path: /mnt/cache/envoy-build-ubuntu-${{ steps.container.outputs.tag }}.tar.zst
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
os_family: ${{ matrix.os_family != '' && matrix.os_family || 'linux' }}
host_platform: ${{ matrix.host_platform != '' && matrix.host_platform || 'ubuntu-22.04' }}
test_toolchain: ${{ github.event_name == 'pull_request' && matrix.target != 'centos' }}
upload_ubuntu_image: ${{ github.event_name == 'pull_request' && matrix.target == 'ubuntu' }}
secrets:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
Expand Down
32 changes: 27 additions & 5 deletions docker/linux/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ config_env() {

# Remove older build instance
docker buildx rm envoy-build-tools-builder &> /dev/null || :
docker buildx create --use --name envoy-build-tools-builder --platform "${BUILD_TOOLS_PLATFORMS}"
docker buildx create \
--use \
--name envoy-build-tools-builder \
--driver-opt network=host \
--platform "${BUILD_TOOLS_PLATFORMS}"
}

[[ -z "${OS_DISTRO}" ]] && OS_DISTRO="ubuntu"
Expand All @@ -26,8 +30,6 @@ if [[ -z "${BUILD_TOOLS_PLATFORMS}" ]]; then
fi
fi

ci_log_run config_env

# TODO(phlax): add (json) build images config
build_and_push_variants () {
if [[ "${OS_DISTRO}" != "ubuntu" ]]; then
Expand Down Expand Up @@ -57,8 +59,12 @@ build_and_push_variants () {
done
}

ci_log_run config_env

ci_log_run docker buildx build . -f "${OS_DISTRO}/Dockerfile" -t "${IMAGE_NAME}:${CONTAINER_TAG}" --target full --platform "${BUILD_TOOLS_PLATFORMS}"

docker ps -a

if [[ -z "${NO_BUILD_VARIANTS}" ]]; then
# variants are only pushed for the dockerhub image (not other `IMAGE_TAGS`)
build_and_push_variants
Expand All @@ -70,6 +76,22 @@ if [[ -n "${IMAGE_TAGS}" ]]; then
fi

if [[ "$LOAD_IMAGE" == "true" ]]; then
# Testing after push to save CI time because this invalidates arm64 cache
ci_log_run docker buildx build . -f "${OS_DISTRO}/Dockerfile" -t "${IMAGE_NAME}:${CONTAINER_TAG}" --platform "linux/amd64" --load

docker ps -a

ci_log_run docker buildx build . \
--push \
-f "${OS_DISTRO}/Dockerfile" \
-t "localhost:5000/${IMAGE_NAME}:${CONTAINER_TAG}" \
--platform "linux/amd64"
ci_log_run docker buildx build . \
--push \
-f "${OS_DISTRO}/Dockerfile" \
-t "localhost:5000/${IMAGE_NAME}:${CONTAINER_TAG}-arm64" \
--platform "linux/arm64"
ci_log_run docker manifest create \
"envoyproxy/envoy-build-ubuntu:${CONTAINER_TAG}-multi" \
"envoyproxy/envoy-build-ubuntu:${CONTAINER_TAG}" \
"envoyproxy/envoy-build-ubuntu:${CONTAINER_TAG}-arm64"

fi
Loading