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

Add docker step to chef cloud build #22885

Merged
merged 17 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from 15 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
31 changes: 31 additions & 0 deletions examples/chef/create_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
#
# Copyright (c) 2021 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

set -e # Exit on any script error.

OUT_DIRECTORY="$WORKING_DIR/out/"

# Clean up the out directory before extracting device files
rm -r "$OUT_DIRECTORY"*

# Extract device files
tar -xf "$TAR_PATH" -C "$OUT_DIRECTORY"

# Build the docker image
docker build -f "$WORKING_DIR"/dockerfile -t "$IMAGE_NAME":latest -t "$IMAGE_NAME:short-sha_$SHORT_SHA" \
-t "$IMAGE_NAME:build-id_$BUILD_ID" -t "$IMAGE_NAME:commit-sha_$COMMIT_SHA" -t "$IMAGE_NAME:revision-id_$REVISION_ID" \
--build-arg DEVICE_NAME="$DEVICE_NAME" .
18 changes: 18 additions & 0 deletions examples/chef/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM debian:bullseye

ARG DEVICE_NAME

RUN apt-get update && \
apt-get install -y \
libglib2.0-0 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

COPY examples/chef/out/${DEVICE_NAME} /chef_device
COPY examples/chef/out/${DEVICE_NAME}.map /chef_device.map
COPY examples/chef/out/${DEVICE_NAME}.matter /chef_device.matter
COPY examples/chef/out/${DEVICE_NAME}_hashmeta.yaml /chef_device_hashmeta.yaml

ENV DBUS_SYSTEM_BUS_ADDRESS="unix:path=/var/run/dbus/system_bus_socket"

CMD ["/chef_device"]
16 changes: 16 additions & 0 deletions integrations/cloudbuild/chef.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ steps:
- name: pwenv
path: /pwenv

- name: "gcr.io/cloud-builders/docker"
args:
- "-c"
- COMMIT_SHA=$COMMIT_SHA SHORT_SHA=$SHORT_SHA REVISION_ID=$REVISION_ID
BUILD_ID=$BUILD_ID IMAGE_NAME=$_DOCKER_IMAGE_NAME
DEVICE_NAME=$_DOCKER_DEVICE_NAME
WORKING_DIR=/workspace/examples/chef
TAR_PATH=/workspace/artifacts/linux_x86-$_DOCKER_DEVICE_NAME.tar.gz
./examples/chef/create_docker.sh
id: DockerAll
entrypoint: /usr/bin/bash
waitFor:
- CompileNoip

logsBucket: matter-build-automation-build-logs

# Global timeout for all steps
Expand All @@ -50,6 +64,8 @@ artifacts:
objects:
location: "gs://matter-build-automation-artifacts/$PROJECT_ID/$COMMIT_SHA/"
paths: ["/workspace/artifacts/*.tar.gz"]
images:
- $_DOCKER_IMAGE_NAME
# Using higher CPU machines generally speeds up builds, except bootstrap is always
# slow.
options:
Expand Down