From afd31dc03e6fd6e2b8273b40b5778f541b034435 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Wed, 18 May 2022 17:25:57 +0200 Subject: [PATCH 1/7] refactor: switch to filiph/linkcheck --- .drone.yml | 18 ++++++++++++++++- .gitignore | 1 + Dockerfile | 41 +++++++++++++++++++------------------- Makefile | 29 +++++++++++++++++++++++++++ README.md | 8 ++++---- overlay/bin/link-validator | 17 +++++++++++++--- 6 files changed, 85 insertions(+), 29 deletions(-) create mode 100644 Makefile diff --git a/.drone.yml b/.drone.yml index f0731c7..368a29e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -27,6 +27,20 @@ platform: arch: amd64 steps: + - name: binary + image: dart:stable + commands: + - apt-get -qq update && apt-get install -yqq --no-install-recommends make + - make build + + - name: verify + image: thegeeklab/alpine-tools + commands: + - src/build/linkcheck/linkcheck --help + - src/build/linkcheck/linkcheck --version + depends_on: + - binary + - name: dryrun image: thegeeklab/drone-docker-buildx:20 settings: @@ -42,6 +56,8 @@ steps: when: ref: - refs/pull/** + depends_on: + - verify - name: tags image: thegeeklab/docker-autotag @@ -153,7 +169,7 @@ steps: DOCKER_USER: from_secret: docker_username PUSHRM_FILE: README.md - PUSHRM_SHORT: Custom image for broken-link-checker + PUSHRM_SHORT: Custom image for linkcheck PUSHRM_TARGET: thegeeklab/${DRONE_REPO_NAME} when: status: diff --git a/.gitignore b/.gitignore index 1b763b1..70cb3fc 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ CHANGELOG.md +/src diff --git a/Dockerfile b/Dockerfile index 8431cd3..a2e4319 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:lts-alpine3.15@sha256:1a9a71ea86aad332aa7740316d4111ee1bd4e890df47d3b5eff3e5bded3b3d10 +FROM debian:bullseye-slim LABEL maintainer="Robert Kaussow " LABEL org.opencontainers.image.authors="Robert Kaussow " @@ -8,34 +8,33 @@ LABEL org.opencontainers.image.source="https://gitea.rknet.org/docker/link-valid LABEL org.opencontainers.image.documentation="https://gitea.rknet.org/docker/link-validator" ARG BUILD_VERSION -# renovate: datasource=npm depName=broken-link-checker -ENV BLC_VERSION="${BUILD_VERSION:-0.7.8}" +ARG WAIT_FOR_VERSION +ARG CONTAINER_LIBRARY + + # renovate: datasource=github-releases depName=caddyserver/caddy -ENV CADDY_VERSION="${CADDY_VERSION:-v2.5.1}" +ENV CADDY_VERSION="${BUILD_VERSION:-v2.5.1}" +# renovate: datasource=github-releases depName=thegeeklab/wait-for +ENV WAIT_FOR_VERSION="${WAIT_FOR_VERSION:-v0.2.0}" +# renovate: datasource=git-tags depName=https://gitea.rknet.org/docker/container-library +ENV CONTAINER_LIBRARY="${CONTAINER_LIBRARY:-v0.1.3}" ENV LINK_VALIDATOR_BASE_DIR=/drone/src \ - LINK_VALIDATOR_SERVER_PORT=80 \ - FORCE_COLOR=true \ - NPM_CONFIG_LOGLEVEL=error + LINK_VALIDATOR_SERVER_PORT=8000 COPY overlay/ / -RUN echo "Installing requirements ..." && \ - apk --update add --virtual .build-deps curl && \ +RUN apt-get update && apt-get install -y curl bash ncat media-types && \ + curl -SsL "https://gitea.rknet.org/docker/container-library/releases/download/${CONTAINER_LIBRARY}/container-library.tar.gz" | tar xz -C / && \ curl -sSL "https://github.com/caddyserver/caddy/releases/download/${CADDY_VERSION}/caddy_${CADDY_VERSION##v}_linux_amd64.tar.gz" | tar xz -C /usr/local/bin caddy && \ + curl -SsL -o /usr/local/bin/wait-for "https://github.com/thegeeklab/wait-for/releases/download/${WAIT_FOR_VERSION}/wait-for" && \ chmod 755 /usr/local/bin/caddy && \ - BLC_VERSION="${BLC_VERSION##v}" && \ - BLC_MAJOR="${BLC_VERSION%%.*}" && \ - if [ -z "${BLC_MAJOR//[0-9]}" ] && [ -n "$BLC_MAJOR" ]; then \ - echo "Installing link-checker version '$BLC_VERSION' ..." && \ - npm install -g broken-link-checker@"$BLC_VERSION"; \ - else \ - echo "Installing latest link-checker ..." && \ - npm install -g broken-link-checker; \ - fi && \ - apk del .build-deps && \ - rm -rf /var/cache/apk/* && \ - rm -rf /tmp/* + chmod 755 /usr/local/bin/wait-for && \ + rm -rf /var/lib/apt/lists/* && \ + rm -rf /tmp/* && \ + rm -rf /root/.cache/ + +ADD src/build/linkcheck/linkcheck /usr/local/bin/linkcheck USER root CMD [] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6ef4427 --- /dev/null +++ b/Makefile @@ -0,0 +1,29 @@ +# renovate: datasource=github-tags depName=filiph/linkcheck +export BUILD_VERSION ?= 2.0.22 +export PATH := $(PATH):$(HOME)/.pub-cache/bin + +SRC := src + +.PHONY: all +all: build + +.PHONY: build +build: build-src build-bin + +.PHONY: build-src +build-src: + mkdir -p $(SRC); \ + curl -sSL "https://github.com/filiph/linkcheck/archive/$${BUILD_VERSION##v}.tar.gz" | tar xz -C $(SRC) --strip-components=1 + +.PHONY: build-bin +build-bin: + dart --disable-analytics --version; \ + cd $(SRC); \ + dart pub get; \ + dart pub global activate grinder; \ + grind pkg-standalone-linux-x64; \ + tar xzf build/linkcheck-*-linux-x64.tar.gz -C ./build + +.PHONY: clean +clean: + rm -rf $(SRC) diff --git a/README.md b/README.md index 7cc4103..cd798f0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # link-validator -Custom image for broken-link-checker +Custom image for linkcheck [![Build Status](https://img.shields.io/drone/build/docker/link-validator?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/docker/link-validator) [![Docker Hub](https://img.shields.io/badge/dockerhub-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/thegeeklab/link-validator) @@ -8,16 +8,16 @@ Custom image for broken-link-checker [![Source: Gitea](https://img.shields.io/badge/source-gitea-blue.svg?logo=gitea&logoColor=white)](https://gitea.rknet.org/docker/link-validator) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitea.rknet.org/docker/link-validator/src/branch/main/LICENSE) -Custom wrapper Docker image for [broken-link-checker](https://github.com/stevenvachon/broken-link-checker) optimized for CI. +Custom wrapper Docker image for [linkcheck](https://github.com/filiph/linkcheck/) optimized for CI. ## Usage ```Shell docker run -v $(pwd)/public:/drone/src link-validator -# or pass arguments to broken-link-checker +# or pass arguments to linkcheck # ... but DO NOT set the server url! This will be done automatically. See environment variables. -docker run -v $(pwd)/public:/drone/src link-validator -ro +docker run -v $(pwd)/public:/drone/src link-validator -e ``` ## Environment variables diff --git a/overlay/bin/link-validator b/overlay/bin/link-validator index cb16513..bdd3ed3 100755 --- a/overlay/bin/link-validator +++ b/overlay/bin/link-validator @@ -1,5 +1,16 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash + set -eo pipefail -caddy file-server --root "$LINK_VALIDATOR_BASE_DIR" --listen "127.0.0.1:$LINK_VALIDATOR_SERVER_PORT" &> /dev/null & -exec /usr/local/bin/broken-link-checker "$@" http://localhost:"$LINK_VALIDATOR_SERVER_PORT" +# shellcheck disable=SC1091 +. /usr/local/lib/log.sh + +URL="127.0.0.1:$LINK_VALIDATOR_SERVER_PORT" + +caddy file-server --root "$LINK_VALIDATOR_BASE_DIR" --listen "$URL" & + +log_info "Wait for web server on '$URL'" +/usr/local/bin/wait-for "$URL" + +log_info "Start linkcheck" +exec /usr/local/bin/linkcheck "$@" "$URL" -- 2.45.2 From ee87ce9327b68eed7f9615e52ddcf89f7e8b3ed6 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Wed, 18 May 2022 17:27:38 +0200 Subject: [PATCH 2/7] sign drone config --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 368a29e..9b16d56 100644 --- a/.drone.yml +++ b/.drone.yml @@ -217,6 +217,6 @@ depends_on: --- kind: signature -hmac: 146d9e41ffdf9ebeae30b044503608af4a872f420cf7f799e70d4ab3a50f4f77 +hmac: affa3b63e8f64b118bb3136a25997b670f7886c623feb19ddfddcca99957510e ... -- 2.45.2 From d87393645533a17c81dcc8e73bdd61983731989b Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Wed, 18 May 2022 17:36:48 +0200 Subject: [PATCH 3/7] debug --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index 9b16d56..6f4847b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -36,6 +36,7 @@ steps: - name: verify image: thegeeklab/alpine-tools commands: + - tree src - src/build/linkcheck/linkcheck --help - src/build/linkcheck/linkcheck --version depends_on: -- 2.45.2 From 15eb1fca8e9b49b41abc5c69856501f9bb748f94 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Wed, 18 May 2022 17:37:13 +0200 Subject: [PATCH 4/7] debug --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 6f4847b..5adaa44 100644 --- a/.drone.yml +++ b/.drone.yml @@ -218,6 +218,6 @@ depends_on: --- kind: signature -hmac: affa3b63e8f64b118bb3136a25997b670f7886c623feb19ddfddcca99957510e +hmac: f28151c98eb52c02e331395dc85847a6461fde84b08c6bffd58a178c65313077 ... -- 2.45.2 From 9d036bf50c9dba905b1cd844ec331ef516a213c2 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Wed, 18 May 2022 17:38:42 +0200 Subject: [PATCH 5/7] debug --- .drone.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 5adaa44..af8d2ca 100644 --- a/.drone.yml +++ b/.drone.yml @@ -36,6 +36,7 @@ steps: - name: verify image: thegeeklab/alpine-tools commands: + - apk add tree - tree src - src/build/linkcheck/linkcheck --help - src/build/linkcheck/linkcheck --version @@ -218,6 +219,6 @@ depends_on: --- kind: signature -hmac: f28151c98eb52c02e331395dc85847a6461fde84b08c6bffd58a178c65313077 +hmac: 9ec54dad33a20a7f0e312b9b00fa5b79aa81c2f33d04ac53efc1568bf8ac9847 ... -- 2.45.2 From a20504416ef3a38582d408759a9ff20f19b7b0e7 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Wed, 18 May 2022 17:39:55 +0200 Subject: [PATCH 6/7] fix verify step --- .drone.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index af8d2ca..6d0b6fd 100644 --- a/.drone.yml +++ b/.drone.yml @@ -34,10 +34,8 @@ steps: - make build - name: verify - image: thegeeklab/alpine-tools + image: dart:stable commands: - - apk add tree - - tree src - src/build/linkcheck/linkcheck --help - src/build/linkcheck/linkcheck --version depends_on: -- 2.45.2 From 8c70652ef4e111e443616ddf3ad00928c9bb397e Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Wed, 18 May 2022 17:40:57 +0200 Subject: [PATCH 7/7] sign drone config --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 6d0b6fd..764660a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -217,6 +217,6 @@ depends_on: --- kind: signature -hmac: 9ec54dad33a20a7f0e312b9b00fa5b79aa81c2f33d04ac53efc1568bf8ac9847 +hmac: c395bc7653458c3fa8c3bd62cb9f615d3af8c53e7c929b1ea90b6c3a71738e6e ... -- 2.45.2