Skip to content

Commit 211f823

Browse files
committed
Use a similar solution to upstream crops#86
1 parent 94827c2 commit 211f823

3 files changed

Lines changed: 90 additions & 5 deletions

File tree

.github/workflows/build-test-deploy.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ jobs:
4646
- uses: actions/checkout@v3
4747

4848
- uses: docker/setup-qemu-action@v2
49+
with:
50+
platforms: linux/amd64,linux/arm64/v8
4951

5052
- uses: docker/setup-buildx-action@v2
5153

@@ -58,7 +60,7 @@ jobs:
5860

5961
# Build and test the images
6062
- name: Run build-and-test.sh
61-
run: ./build_container.sh
63+
run: ./buildx_container.sh
6264

6365
# Deploy the images
6466
- name: Deploy

build_container.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ cd $workdir
3434
baseimage=`grep FROM Dockerfile | sed -e 's/FROM //'`
3535
${ENGINE_CMD} pull $baseimage
3636

37-
${ENGINE_CMD} buildx build \
38-
--platform=linux/amd64,linux/arm64/v8 \
37+
${ENGINE_CMD} build \
3938
--build-arg http_proxy=$http_proxy \
4039
--build-arg HTTP_PROXY=$http_proxy \
4140
--build-arg https_proxy=$https_proxy \
@@ -63,8 +62,7 @@ cd $workdir
6362
sed -i -e "s#crops/yocto#$REPO#" Dockerfile
6463

6564
# Lastly build the image
66-
${ENGINE_CMD} buildx build \
67-
--platform=linux/amd64,linux/arm64/v8 \
65+
${ENGINE_CMD} build \
6866
--build-arg http_proxy=$http_proxy \
6967
--build-arg HTTP_PROXY=$http_proxy \
7068
--build-arg https_proxy=$https_proxy \

buildx_container.sh

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/bash
2+
3+
# build-container.sh
4+
#
5+
# Copyright (C) 2016-2021 Intel Corporation
6+
#
7+
# SPDX-License-Identifier: GPL-2.0-only
8+
#
9+
10+
set -e
11+
12+
# Allow the user to specify another command to use for building such as podman
13+
if [ "${ENGINE_CMD}" = "" ]; then
14+
ENGINE_CMD="docker"
15+
fi
16+
17+
# DISTRO_TO_BUILD is essentially the prefix to the "base" and "builder"
18+
# directories you plan to use. i.e. "fedora-23" or "ubuntu-16.04"
19+
20+
# First build the base
21+
TAG=$DISTRO_TO_BUILD-base
22+
dockerdir=`find -name $TAG`
23+
workdir=`mktemp --tmpdir -d tmp-$TAG.XXX`
24+
25+
cp -r $dockerdir $workdir
26+
workdir=$workdir/$TAG
27+
28+
cp install-multilib.sh $workdir
29+
cp build-install-dumb-init.sh $workdir
30+
cp install-buildtools.sh $workdir
31+
cp install-buildtools-make.sh $workdir
32+
cd $workdir
33+
34+
baseimage=`grep FROM Dockerfile | sed -e 's/FROM //'`
35+
${ENGINE_CMD} pull $baseimage
36+
37+
${ENGINE_CMD} buildx build \
38+
--platform=linux/amd64,linux/arm64/v8 \
39+
--build-arg http_proxy=$http_proxy \
40+
--build-arg HTTP_PROXY=$http_proxy \
41+
--build-arg https_proxy=$https_proxy \
42+
--build-arg HTTPS_PROXY=$https_proxy \
43+
--build-arg no_proxy=$no_proxy \
44+
--build-arg NO_PROXY=$no_proxy \
45+
-t $REPO:$TAG .
46+
rm $workdir -rf
47+
cd -
48+
49+
# Now build the builder. We copy things to a temporary directory so that we
50+
# can modify the Dockerfile to use whatever REPO is in the environment.
51+
TAG=$DISTRO_TO_BUILD-builder
52+
workdir=`mktemp --tmpdir -d tmp-$TAG.XXX`
53+
54+
# use the builder template to populate the distro specific Dockerfile
55+
cp dockerfiles/templates/Dockerfile.builder $workdir/Dockerfile
56+
cp distro-entry.sh $workdir
57+
sed -i "s/DISTRO_TO_BUILD/$DISTRO_TO_BUILD/g" $workdir/Dockerfile
58+
59+
cp helpers/runbitbake.py $workdir
60+
cd $workdir
61+
62+
# Replace the rewitt/yocto repo with the one from environment
63+
sed -i -e "s#crops/yocto#$REPO#" Dockerfile
64+
65+
# Lastly build the image
66+
${ENGINE_CMD} buildx build \
67+
--platform=linux/amd64,linux/arm64/v8 \
68+
--build-arg http_proxy=$http_proxy \
69+
--build-arg HTTP_PROXY=$http_proxy \
70+
--build-arg https_proxy=$https_proxy \
71+
--build-arg HTTPS_PROXY=$https_proxy \
72+
--build-arg no_proxy=$no_proxy \
73+
--build-arg NO_PROXY=$no_proxy \
74+
-t $REPO:$TAG .
75+
cd -
76+
77+
# base tests
78+
ENGINE_CMD=${ENGINE_CMD}
79+
./tests/container/vnc-test.sh $REPO:$DISTRO_TO_BUILD-base
80+
# builder tests
81+
ENGINE_CMD=${ENGINE_CMD}
82+
./tests/container/smoke.sh $REPO:$DISTRO_TO_BUILD-builder
83+
84+
rm $workdir -rf
85+

0 commit comments

Comments
 (0)