From ff63fd2d65938e7e003d1e6bd50a0fc84bd39ba4 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Tue, 18 Feb 2020 17:24:11 +0100 Subject: [PATCH] Unify build process, add golangci-lint Signed-off-by: Knut Ahlers --- Dockerfile | 9 +-------- build.sh | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index ad25d5e..90d8637 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,14 +7,7 @@ COPY build.sh /usr/local/bin/ RUN set -ex \ && apk --no-cache add \ bash \ - ca-certificates \ - curl \ - docker \ - git \ - jq \ - make \ - && /usr/local/bin/build.sh \ - && apk --no-cache del --purge jq + && /usr/local/bin/build.sh ENTRYPOINT ["/usr/local/bin/inner-runner"] CMD ["--"] diff --git a/build.sh b/build.sh index a3cee22..e68b938 100755 --- a/build.sh +++ b/build.sh @@ -1,8 +1,37 @@ #!/bin/bash set -euxo pipefail +# Packages required to build the image +pkg_build=( + jq + tar +) + +# Packages kept for the final image +pkg_img=( + bash + ca-certificates + curl + docker + git + make +) + +# Install required packages +apk --no-cache add "${pkg_build[@]}" "${pkg_img[@]}" + +function get_asset_url() { + curl -sSfL "https://api.github.com/repos/${1}/releases/latest" | + jq -r '.assets | .[] | .browser_download_url' | + grep -E 'linux.*amd64' +} + # Download latest release of inner-runner -DOWNLOAD=$(curl -sSfL https://api.github.com/repos/repo-runner/repo-runner/releases/latest | - jq -r '.assets | .[] | select(.name == "inner-runner_linux_amd64.tar.gz") | .browser_download_url') -curl -sSfL "${DOWNLOAD}" | tar -xzf - -C /usr/local/bin +curl -sSfL "$(get_asset_url repo-runner/repo-runner | grep inner-runner)" | tar -xzf - -C /usr/local/bin mv /usr/local/bin/inner-runner* /usr/local/bin/inner-runner + +# Download latest release of golangci-lint +curl -sSfL "$(get_asset_url golangci/golangci-lint)" | tar -xzf - -C /usr/local/bin --wildcards '*/golangci-lint' --strip-components=1 + +# Purge build-packages +apk --no-cache del --purge "${pkg_build[@]}"