Skip to content

Commit 380c23c

Browse files
committed
build-linux-selfcontained.sh: use docker copy instead of volumes
.. to support docker-in-docker runs.
1 parent e18d8d6 commit 380c23c

File tree

1 file changed

+58
-18
lines changed

1 file changed

+58
-18
lines changed

tools/build-linux-selfcontained.sh

Lines changed: 58 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,75 @@
44
# Builds autonomous Python packages including all available dependencies
55
# using docker.
66
#
7-
# This is a tiny linux alternative to cibuildwheel as a workaround
8-
# to provide --volumes-from=.. on docker-in-docker builds.
7+
# This is a tiny linux alternative to cibuildwheel on linux that does
8+
# not rely on Docker volumes to work (such as for docker-in-docker).
9+
#
10+
# The in-docker portion of this script is based on cibuildwheel's counterpart.
911
#
1012

11-
if [[ $# -lt 3 ]]; then
12-
echo "Usage: $0 <librdkafka_tag> <repo-dir-full-path> <relative-out-dir>"
13+
if [[ $# -ne 2 ]]; then
14+
echo "Usage: $0 <librdkafka_tag> <out-dir>"
1315
exit 1
1416
fi
1517

1618
set -ex
1719

1820
if [[ $1 != "--in-docker" ]]; then
1921
# Outside our docker
20-
workdir=$2
21-
if [[ -f /.dockerenv ]]; then
22-
echo "$0: $HOSTNAME: Currently running from inside docker: exposing host mounts"
23-
docker run -i --volumes-from=$HOSTNAME quay.io/pypa/manylinux1_x86_64 $workdir/tools/build-linux-selfcontained.sh --in-docker $1 $2 $3
24-
else
25-
echo "$0: $HOSTNAME: Not currently running from inside docker: exposing $2 as volume"
26-
docker run -i -v $workdir:$workdir quay.io/pypa/manylinux1_x86_64 $workdir/tools/build-linux-selfcontained.sh --in-docker $1 $2 $3
27-
fi
22+
LIBRDKAFKA_VERSION=$1
23+
outdir=$2
24+
[[ ! -d $outdir ]] || mkdir -p $outdir
25+
26+
docker_image=quay.io/pypa/manylinux1_x86_64
27+
28+
script_in_docker=/tmp/$(basename $0)
29+
30+
# Create container
31+
container=$(basename $(mktemp -u pywhlXXXXXX))
32+
docker create -i --name $container $docker_image $script_in_docker --in-docker $LIBRDKAFKA_VERSION
33+
34+
# Create archive
35+
git archive -o src.tar.gz HEAD
36+
37+
# Copy this script to container
38+
docker cp $0 $container:$script_in_docker
39+
40+
# Copy archive to container
41+
docker cp src.tar.gz $container:/tmp/
42+
43+
# Run this script in docker
44+
docker start -i $container
45+
46+
# Copy artifacts from container
47+
rm -rf $outdir/output
48+
docker cp $container:/output $outdir/
49+
mv $outdir/output/* $outdir/
50+
rm -rf $outdir/output
51+
52+
# Remove container
53+
docker rm $container
54+
55+
echo "Artifacts now available in $outdir:"
56+
ls -la $outdir/
57+
2858
exit 0
2959
fi
3060

61+
3162
#
3263
# Inside our docker
3364
#
3465

66+
if [[ $# -ne $2 ]]; then
67+
echo "Inner usage: $0 --in-docker <librdkafka_tag>"
68+
exit 1
69+
fi
70+
3571
echo "$0: $HOSTNAME: Run"
3672

3773
shift # remove --in-docker
3874

3975
LIBRDKAFKA_VERSION=$1
40-
WORKDIR=$2
41-
OUTDIR=$3
4276

4377

4478
function install_deps {
@@ -49,25 +83,28 @@ function install_deps {
4983
yum install -y zlib-devel gcc gcc-c++ libstdc++-devel
5084

5185
# Build OpenSSL
52-
$(dirname $0)/build-openssl.sh /usr
86+
tools/build-openssl.sh /usr
5387

5488
fi
5589
}
5690

5791
function build_librdkafka {
5892
local dest=$1
5993
echo "# Building librdkafka ${LIBRDKAFKA_VERSION}"
60-
$(dirname $0)/bootstrap-librdkafka.sh --require-ssl ${LIBRDKAFKA_VERSION} $dest
94+
tools/bootstrap-librdkafka.sh --require-ssl ${LIBRDKAFKA_VERSION} $dest
6195

6296
}
6397

6498

6599
function build {
66100
local workdir=$1
67-
local outdir=$2
101+
local outdir=/output
68102

103+
mkdir -p $workdir
69104
pushd $workdir
70105

106+
tar xvzf /tmp/src.tar.gz
107+
71108
install_deps
72109

73110
build_librdkafka /usr
@@ -101,10 +138,13 @@ function build {
101138

102139
# we're all done here; move it to output
103140
mv "$delocated_wheel" $outdir/
141+
ls -la $outdir/
104142
done
105143

106144
popd # workdir
107145
}
108146

109-
build $WORKDIR $OUTDIR
147+
echo "$0: $HOSTNAME: Building in docker"
148+
build /build
149+
echo "$0: $HOSTNAME: Done"
110150

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy