Unify build process, add golangci-lint

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2020-02-18 17:24:11 +01:00
parent d87257f111
commit ff63fd2d65
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
2 changed files with 33 additions and 11 deletions

View file

@ -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 ["--"]

View file

@ -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[@]}"