0682468431
This reduces memory usage with a lot of docker proxy processes. On Docker for Mac we are currently carrying a patch to replace the binary as we modify it to forward ports to the Mac rather than the Linux VM, this allows us to simply replace this binary in our packaging with one that has a compatible interface. This patch does not provide an easy way to substitute a binary as the interface is complex and there are few use cases, but where needed this can be done. Signed-off-by: Justin Cormack <justin.cormack@docker.com>
82 lines
2.3 KiB
Bash
82 lines
2.3 KiB
Bash
#!/bin/bash
|
|
|
|
CROSS="$DEST/../cross"
|
|
|
|
set -e
|
|
|
|
if [ ! -d "$CROSS/linux/amd64" ]; then
|
|
echo >&2 'error: binary and cross must be run before tgz'
|
|
false
|
|
fi
|
|
|
|
(
|
|
for d in "$CROSS/"*/*; do
|
|
export GOARCH="$(basename "$d")"
|
|
export GOOS="$(basename "$(dirname "$d")")"
|
|
|
|
source "${MAKEDIR}/.binary-setup"
|
|
|
|
BINARY_NAME="${DOCKER_CLIENT_BINARY_NAME}-$VERSION"
|
|
DAEMON_BINARY_NAME="${DOCKER_DAEMON_BINARY_NAME}-$VERSION"
|
|
PROXY_BINARY_NAME="${DOCKER_PROXY_BINARY_NAME}-$VERSION"
|
|
BINARY_EXTENSION="$(export GOOS && binary_extension)"
|
|
if [ "$GOOS" = 'windows' ]; then
|
|
# if windows use a zip, not tgz
|
|
BUNDLE_EXTENSION=".zip"
|
|
IS_TAR="false"
|
|
else
|
|
BUNDLE_EXTENSION=".tgz"
|
|
IS_TAR="true"
|
|
fi
|
|
BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION"
|
|
DAEMON_BINARY_FULLNAME="$DAEMON_BINARY_NAME$BINARY_EXTENSION"
|
|
PROXY_BINARY_FULLNAME="$PROXY_BINARY_NAME$BINARY_EXTENSION"
|
|
mkdir -p "$DEST/$GOOS/$GOARCH"
|
|
TGZ="$DEST/$GOOS/$GOARCH/$BINARY_NAME$BUNDLE_EXTENSION"
|
|
|
|
# The staging directory for the files in the tgz
|
|
BUILD_PATH="$DEST/build"
|
|
|
|
# The directory that is at the root of the tar file
|
|
TAR_BASE_DIRECTORY="docker"
|
|
|
|
# $DEST/build/docker
|
|
TAR_PATH="$BUILD_PATH/$TAR_BASE_DIRECTORY"
|
|
|
|
# Copy the correct docker binary
|
|
mkdir -p $TAR_PATH
|
|
cp -L "$d/$BINARY_FULLNAME" "$TAR_PATH/${DOCKER_CLIENT_BINARY_NAME}${BINARY_EXTENSION}"
|
|
if [ -f "$d/$DAEMON_BINARY_FULLNAME" ]; then
|
|
cp -L "$d/$DAEMON_BINARY_FULLNAME" "$TAR_PATH/${DOCKER_DAEMON_BINARY_NAME}${BINARY_EXTENSION}"
|
|
fi
|
|
if [ -f "$d/$PROXY_BINARY_FULLNAME" ]; then
|
|
cp -L "$d/$PROXY_BINARY_FULLNAME" "$TAR_PATH/${DOCKER_PROXY_BINARY_NAME}${BINARY_EXTENSION}"
|
|
fi
|
|
|
|
# copy over all the containerd binaries
|
|
copy_containerd $TAR_PATH
|
|
|
|
if [ "$IS_TAR" == "true" ]; then
|
|
echo "Creating tgz from $BUILD_PATH and naming it $TGZ"
|
|
tar --numeric-owner --owner 0 -C "$BUILD_PATH" -czf "$TGZ" $TAR_BASE_DIRECTORY
|
|
else
|
|
# ZIP needs to full absolute dir path, not the absolute path
|
|
ZIP=`pwd`"/$TGZ"
|
|
# keep track of where we are, for later.
|
|
pushd .
|
|
# go into the BUILD_PATH since zip does not have a -C equivalent.
|
|
cd $BUILD_PATH
|
|
echo "Creating zip from $BUILD_PATH and naming it $ZIP"
|
|
zip -q -r $ZIP $TAR_BASE_DIRECTORY
|
|
# go back to where we started
|
|
popd
|
|
fi
|
|
|
|
hash_files "$TGZ"
|
|
|
|
# cleanup after ourselves
|
|
rm -rf "$BUILD_PATH"
|
|
|
|
echo "Created tgz: $TGZ"
|
|
done
|
|
)
|