mirror of https://github.com/docker/compose.git
build: Refactor to use BuildKit
Signed-off-by: Chris Crone <christopher.crone@docker.com>
This commit is contained in:
parent
675c9674e1
commit
f825cec2fc
16
Dockerfile
16
Dockerfile
|
@ -5,7 +5,7 @@ ARG BUILD_DEBIAN_VERSION=slim-stretch
|
|||
ARG RUNTIME_ALPINE_VERSION=3.11.5
|
||||
ARG RUNTIME_DEBIAN_VERSION=stretch-20200414-slim
|
||||
|
||||
ARG BUILD_PLATFORM=alpine
|
||||
ARG DISTRO=alpine
|
||||
|
||||
FROM docker:${DOCKER_VERSION} AS docker-cli
|
||||
|
||||
|
@ -40,15 +40,14 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
|
|||
openssl \
|
||||
zlib1g-dev
|
||||
|
||||
FROM build-${BUILD_PLATFORM} AS build
|
||||
COPY docker-compose-entrypoint.sh /usr/local/bin/
|
||||
FROM build-${DISTRO} AS build
|
||||
ENTRYPOINT ["sh", "/usr/local/bin/docker-compose-entrypoint.sh"]
|
||||
COPY --from=docker-cli /usr/local/bin/docker /usr/local/bin/docker
|
||||
WORKDIR /code/
|
||||
COPY docker-compose-entrypoint.sh /usr/local/bin/
|
||||
COPY --from=docker-cli /usr/local/bin/docker /usr/local/bin/docker
|
||||
RUN pip install \
|
||||
virtualenv==20.0.30 \
|
||||
tox==3.19.0
|
||||
|
||||
COPY requirements-dev.txt .
|
||||
COPY requirements-indirect.txt .
|
||||
COPY requirements.txt .
|
||||
|
@ -64,9 +63,14 @@ ARG GIT_COMMIT=unknown
|
|||
ENV DOCKER_COMPOSE_GITSHA=$GIT_COMMIT
|
||||
RUN script/build/linux-entrypoint
|
||||
|
||||
FROM scratch AS bin
|
||||
ARG TARGETARCH
|
||||
ARG TARGETOS
|
||||
COPY --from=build /usr/local/bin/docker-compose /docker-compose-${TARGETOS}-${TARGETARCH}
|
||||
|
||||
FROM alpine:${RUNTIME_ALPINE_VERSION} AS runtime-alpine
|
||||
FROM debian:${RUNTIME_DEBIAN_VERSION} AS runtime-debian
|
||||
FROM runtime-${BUILD_PLATFORM} AS runtime
|
||||
FROM runtime-${DISTRO} AS runtime
|
||||
COPY docker-compose-entrypoint.sh /usr/local/bin/
|
||||
ENTRYPOINT ["sh", "/usr/local/bin/docker-compose-entrypoint.sh"]
|
||||
COPY --from=docker-cli /usr/local/bin/docker /usr/local/bin/docker
|
||||
|
|
|
@ -13,6 +13,9 @@ pipeline {
|
|||
timeout(time: 2, unit: 'HOURS')
|
||||
timestamps()
|
||||
}
|
||||
environment {
|
||||
DOCKER_BUILDKIT="1"
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Build test images') {
|
||||
|
@ -69,7 +72,7 @@ def buildImage(baseImage) {
|
|||
ansiColor('xterm') {
|
||||
sh """docker build -t ${imageName} \\
|
||||
--target build \\
|
||||
--build-arg BUILD_PLATFORM="${baseImage}" \\
|
||||
--build-arg DISTRO="${baseImage}" \\
|
||||
--build-arg GIT_COMMIT="${scmvar.GIT_COMMIT}" \\
|
||||
.\\
|
||||
"""
|
||||
|
|
|
@ -13,6 +13,9 @@ pipeline {
|
|||
timeout(time: 2, unit: 'HOURS')
|
||||
timestamps()
|
||||
}
|
||||
environment {
|
||||
DOCKER_BUILDKIT="1"
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Build test images') {
|
||||
|
@ -229,7 +232,7 @@ def buildImage(baseImage) {
|
|||
ansiColor('xterm') {
|
||||
sh """docker build -t ${imageName} \\
|
||||
--target build \\
|
||||
--build-arg BUILD_PLATFORM="${baseImage}" \\
|
||||
--build-arg DISTRO="${baseImage}" \\
|
||||
--build-arg GIT_COMMIT="${scmvar.GIT_COMMIT}" \\
|
||||
.\\
|
||||
"""
|
||||
|
@ -276,7 +279,7 @@ def buildRuntimeImage(baseImage) {
|
|||
def imageName = "docker/compose:${baseImage}-${env.BRANCH_NAME}"
|
||||
ansiColor('xterm') {
|
||||
sh """docker build -t ${imageName} \\
|
||||
--build-arg BUILD_PLATFORM="${baseImage}" \\
|
||||
--build-arg DISTRO="${baseImage}" \\
|
||||
--build-arg GIT_COMMIT="${scmvar.GIT_COMMIT.take(7)}" \\
|
||||
.
|
||||
"""
|
||||
|
|
|
@ -5,14 +5,12 @@ set -ex
|
|||
./script/clean
|
||||
|
||||
DOCKER_COMPOSE_GITSHA="$(script/build/write-git-sha)"
|
||||
TAG="docker/compose:tmp-glibc-linux-binary-${DOCKER_COMPOSE_GITSHA}"
|
||||
|
||||
docker build -t "${TAG}" . \
|
||||
--build-arg BUILD_PLATFORM=debian \
|
||||
--build-arg GIT_COMMIT="${DOCKER_COMPOSE_GITSHA}"
|
||||
TMP_CONTAINER=$(docker create "${TAG}")
|
||||
mkdir -p dist
|
||||
docker build . \
|
||||
--target bin \
|
||||
--build-arg DISTRO=debian \
|
||||
--build-arg GIT_COMMIT="${DOCKER_COMPOSE_GITSHA}" \
|
||||
--output dist/
|
||||
ARCH=$(uname -m)
|
||||
docker cp "${TMP_CONTAINER}":/usr/local/bin/docker-compose "dist/docker-compose-Linux-${ARCH}"
|
||||
docker container rm -f "${TMP_CONTAINER}"
|
||||
docker image rm -f "${TAG}"
|
||||
# Ensure that we output the binary with the same name as we did before
|
||||
mv dist/docker-compose-linux-amd64 "dist/docker-compose-Linux-${ARCH}"
|
||||
|
|
|
@ -13,6 +13,6 @@ IMAGE="docker/compose-tests"
|
|||
DOCKER_COMPOSE_GITSHA="$(script/build/write-git-sha)"
|
||||
docker build -t "${IMAGE}:${TAG}" . \
|
||||
--target build \
|
||||
--build-arg BUILD_PLATFORM="debian" \
|
||||
--build-arg DISTRO="debian" \
|
||||
--build-arg GIT_COMMIT="${DOCKER_COMPOSE_GITSHA}"
|
||||
docker tag "${IMAGE}":"${TAG}" "${IMAGE}":latest
|
||||
|
|
Loading…
Reference in New Issue