Skip to content

Commit

Permalink
Add docker step to chef cloud build (#22885)
Browse files Browse the repository at this point in the history
* Add chef dockerfile

* Add script for building chef docker images

* Add chef dockerization cloud step

* Restyled by whitespace

* Restyled by prettier-yaml

* Restyled by shellharden

* Remove hardcoded values from docker script

* Restyled by prettier-yaml

* Restyled by shellharden

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
FernandoLGuzman and restyled-commits authored Oct 14, 2022
1 parent bc6b438 commit e017be1
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
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

0 comments on commit e017be1

Please sign in to comment.