Skip to content

Commit

Permalink
static: add compose
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Feb 4, 2023
1 parent 260349d commit 3e86f53
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
4 changes: 3 additions & 1 deletion static/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ include ../common.mk
CLI_DIR=$(realpath $(CURDIR)/../src/github.com/docker/cli)
ENGINE_DIR=$(realpath $(CURDIR)/../src/github.com/docker/docker)
BUILDX_DIR=$(realpath $(CURDIR)/../src/github.com/docker/buildx)
COMPOSE_DIR=$(realpath $(CURDIR)/../src/github.com/docker/compose)

ENGINE_GITCOMMIT?=$(shell cd $(realpath $(CURDIR)/../src/github.com/docker/docker) && git rev-parse --short HEAD)
GEN_STATIC_VER=$(shell ./gen-static-ver $(CLI_DIR) $(VERSION))
Expand All @@ -17,6 +18,7 @@ RUNC_VERSION?=$(shell grep "ARG RUNC_VERSION" "$(ENGINE_DIR)/Dockerfile" | awk -
export CLI_DIR
export ENGINE_DIR
export BUILDX_DIR
export COMPOSE_DIR
export GEN_STATIC_VER
export CONTAINERD_VERSION
export RUNC_VERSION
Expand All @@ -25,8 +27,8 @@ export REF
export DOCKER_CLI_REF
export DOCKER_ENGINE_REF
export DOCKER_SCAN_REF
export DOCKER_COMPOSE_REF
export DOCKER_BUILDX_REF
export DOCKER_COMPOSE_REF

export GO_VERSION

Expand Down
47 changes: 47 additions & 0 deletions static/build-static
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,19 @@ build_buildx() {
)
}

build_compose() {
(
cd "${COMPOSE_DIR}"
set -x
docker buildx build \
--platform "${TARGETPLATFORM}" \
--build-arg BUILDKIT_MULTI_PLATFORM=true \
--build-arg GO_VERSION \
--output ./bin \
--target binary .
)
}

echo "TARGETPLATFORM=${TARGETPLATFORM}"
echo "CONTAINERD_VERSION=${CONTAINERD_VERSION}"
echo "RUNC_VERSION=${RUNC_VERSION}"
Expand All @@ -142,26 +155,31 @@ dockerBuildDir="${buildDir}/docker"
containerdBuildDir="${buildDir}/containerd"
rootlessExtrasBuildDir="${buildDir}/docker-rootless-extras"
buildxBuildDir="${buildDir}/docker-buildx"
composeBuildDir="${buildDir}/docker-compose"

# clean up previous build output dirs
[ -d "${CLI_DIR:?}/build" ] && rm -r "${CLI_DIR:?}/build"
[ -d "${ENGINE_DIR:?}/build" ] && rm -r "${ENGINE_DIR:?}/build"
[ -d "${BUILDX_DIR:?}/bin" ] && rm -r "${BUILDX_DIR:?}/bin"
[ -d "${COMPOSE_DIR:?}/bin" ] && rm -r "${COMPOSE_DIR:?}/bin"

case ${TARGETOS} in
linux)
build_cli
build_engine
build_buildx
build_compose
;;
darwin)
build_cli
build_buildx
build_compose
;;
windows)
build_cli
build_engine
build_buildx
build_compose
;;
esac

Expand Down Expand Up @@ -322,6 +340,35 @@ if [ -d "${BUILDX_DIR}/bin" ]; then
esac
fi

# compose
if [ -d "${COMPOSE_DIR}/bin" ]; then
mkdir -p "${composeBuildDir}"
case ${TARGETOS} in
linux | darwin)
cp "${COMPOSE_DIR}/bin/docker-compose" "${composeBuildDir}/docker-compose"
;;
windows)
cp "${COMPOSE_DIR}/bin/docker-compose.exe" "${composeBuildDir}/docker-compose.exe"
;;
esac
# package compose
case ${TARGETOS} in
linux | darwin)
(
set -x
tar -C "${buildDir}" -c -z -f "${buildDir}/docker-compose-plugin-${DOCKER_COMPOSE_REF#v}.tgz" docker-compose
)
;;
windows)
(
cd "${buildDir}"
set -x
zip -r "docker-compose-plugin-${DOCKER_COMPOSE_REF#v}.zip" docker-compose
)
;;
esac
fi

# create bundle
(
# bundle is expected to have a tar.gz extension, unlike the other archives, which use .tgz
Expand Down

0 comments on commit 3e86f53

Please sign in to comment.