From ef7f651966e665d4fc5a94de6c6099fd08e95f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Busso?= Date: Wed, 23 Dec 2020 10:07:55 +1300 Subject: [PATCH] Fix wget --- build/download_docker_compose_binary.ps1 | 7 ++++ build/download_docker_compose_binary.sh | 15 ++++++++ build/linux/compose.Dockerfile | 47 ------------------------ gruntfile.js | 34 ++++++++++++++++- 4 files changed, 55 insertions(+), 48 deletions(-) create mode 100755 build/download_docker_compose_binary.ps1 create mode 100755 build/download_docker_compose_binary.sh delete mode 100644 build/linux/compose.Dockerfile diff --git a/build/download_docker_compose_binary.ps1 b/build/download_docker_compose_binary.ps1 new file mode 100755 index 000000000..0ec5bf84c --- /dev/null +++ b/build/download_docker_compose_binary.ps1 @@ -0,0 +1,7 @@ +param ( + [string]$docker_compose_version +) + +$ErrorActionPreference = "Stop"; + +Invoke-WebRequest -O "dist/docker-compose.exe" "https://github.com/docker/compose/releases/download/$($docker_compose_version)/docker-compose-Windows-x86_64.exe" diff --git a/build/download_docker_compose_binary.sh b/build/download_docker_compose_binary.sh new file mode 100755 index 000000000..55fb214b7 --- /dev/null +++ b/build/download_docker_compose_binary.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +PLATFORM=$1 +ARCH=$2 +DOCKER_COMPOSE_VERSION=$3 + +if [ "${PLATFORM}" == 'win' ]; then + wget -O "dist/docker-compose.exe" "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-Windows-x86_64.exe" +elif [ "${PLATFORM}" == 'linux' ] && [ "${ARCH}" == 'amd64' ]; then + wget -O "dist/docker-compose" "https://github.com/portainer/docker-compose-linux-amd64-static-binary/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose" + chmod +x "dist/docker-compose" +fi + +exit 0 + diff --git a/build/linux/compose.Dockerfile b/build/linux/compose.Dockerfile deleted file mode 100644 index 7bdce920b..000000000 --- a/build/linux/compose.Dockerfile +++ /dev/null @@ -1,47 +0,0 @@ -# Dockerfile to build docker-compose for linux amd64 -FROM python:3.6.5-stretch as builder -# Add env -ENV LANG C.UTF-8 - -RUN apt-get update && apt-get install -qq --no-install-recommends unzip patchelf - -# Set the versions -ARG DOCKER_COMPOSE_VER=1.27.4 -# docker-compose requires pyinstaller 3.5 (check github.com/docker/compose/requirements-build.txt) -# If this changes, you may need to modify the version of "six" below -ENV PYINSTALLER_VER 3.5 -# "six" is needed for PyInstaller. v1.11.0 is the latest as of PyInstaller 3.5 -ENV SIX_VER 1.11.0 - -# Install dependencies -RUN pip install --upgrade pip -RUN pip install six==$SIX_VER -RUN pip install staticx - -# Compile the pyinstaller "bootloader" -# https://pyinstaller.readthedocs.io/en/stable/bootloader-building.html -WORKDIR /build/pyinstallerbootloader -RUN curl -fsSL https://github.com/pyinstaller/pyinstaller/releases/download/v$PYINSTALLER_VER/PyInstaller-$PYINSTALLER_VER.tar.gz | tar xvz >/dev/null \ - && cd PyInstaller*/bootloader \ - && python3 ./waf all - -# Clone docker-compose -WORKDIR /build/dockercompose -RUN curl -fsSL https://github.com/docker/compose/archive/$DOCKER_COMPOSE_VER.zip > $DOCKER_COMPOSE_VER.zip \ - && unzip $DOCKER_COMPOSE_VER.zip - -# Run the build steps (taken from https://github.com/docker/compose/blob/master/script/build/linux-entrypoint) -RUN cd compose-$DOCKER_COMPOSE_VER && mkdir ./dist \ - && pip install -r requirements.txt -r requirements-build.txt - -RUN cd compose-$DOCKER_COMPOSE_VER \ - && echo "unknown" > compose/GITSHA \ - && pyinstaller -F docker-compose.spec \ - && mkdir /dist \ - && staticx dist/docker-compose /dist/docker-compose - -FROM scratch -COPY dist / -COPY --from=builder /dist/docker-compose /docker-compose - -entrypoint ["/docker-compose"] \ No newline at end of file diff --git a/gruntfile.js b/gruntfile.js index c9da104db..e1c91179c 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -19,7 +19,8 @@ module.exports = function (grunt) { binaries: { dockerLinuxVersion: '18.09.3', dockerWindowsVersion: '17.09.0-ce', - komposeVersion: 'v1.21.0', + dockerComposeVersion: '1.27.4', + komposeVersion: 'v1.22.0', kubectlVersion: 'v1.18.0', }, config: gruntfile_cfg.config, @@ -37,6 +38,7 @@ module.exports = function (grunt) { grunt.registerTask('build:server', [ 'shell:build_binary:linux:' + arch, 'shell:download_docker_binary:linux:' + arch, + 'shell:download_docker_compose_binary:linux:' + arch, 'shell:download_kompose_binary:linux:' + arch, 'shell:download_kubectl_binary:linux:' + arch, ]); @@ -63,6 +65,7 @@ module.exports = function (grunt) { 'copy:assets', 'shell:build_binary:' + p + ':' + a, 'shell:download_docker_binary:' + p + ':' + a, + 'shell:download_docker_compose_binary:' + p + ':' + a, 'shell:download_kompose_binary:' + p + ':' + a, 'shell:download_kubectl_binary:' + p + ':' + a, 'webpack:prod', @@ -77,6 +80,7 @@ module.exports = function (grunt) { 'copy:assets', 'shell:build_binary_azuredevops:' + p + ':' + a, 'shell:download_docker_binary:' + p + ':' + a, + 'shell:download_docker_compose_binary:' + p + ':' + a, 'shell:download_kompose_binary:' + p + ':' + a, 'shell:download_kubectl_binary:' + p + ':' + a, 'webpack:prod', @@ -138,6 +142,7 @@ gruntfile_cfg.shell = { download_docker_binary: { command: shell_download_docker_binary }, download_kompose_binary: { command: shell_download_kompose_binary }, download_kubectl_binary: { command: shell_download_kubectl_binary }, + download_docker_compose_binary: { command: shell_download_docker_compose_binary }, run_container: { command: shell_run_container }, run_localserver: { command: shell_run_localserver, options: { async: true } }, install_yarndeps: { command: shell_install_yarndeps }, @@ -204,6 +209,33 @@ function shell_download_docker_binary(p, a) { } } +function shell_download_docker_compose_binary(p, a) { + var ps = { windows: 'win', darwin: 'mac' }; + var as = { amd64: 'x86_64', arm: 'armhf', arm64: 'aarch64' }; + var ip = ps[p] === undefined ? p : ps[p]; + var ia = as[a] === undefined ? a : as[a]; + var binaryVersion = '<%= binaries.dockerComposeVersion %>'; + + if (p === 'linux' || p === 'mac') { + return [ + 'if [ -f dist/docker ]; then', + 'echo "Docker Compose binary exists";', + 'else', + 'build/download_docker_compose_binary.sh ' + ip + ' ' + ia + ' ' + binaryVersion + ';', + 'fi', + ].join(' '); + } else { + return [ + 'powershell -Command "& {if (Test-Path -Path "dist/docker-compose.exe") {', + 'Write-Host "Skipping download, Docker Compose binary exists"', + 'return', + '} else {', + '& ".\\build\\download_docker_compose_binary.ps1" -docker_compose_version ' + binaryVersion + '', + '}}"', + ].join(' '); + } +} + function shell_download_kompose_binary(p, a) { var binaryVersion = '<%= binaries.komposeVersion %>';