refactor: switch to filiph/linkcheck #76
20
.drone.yml
20
.drone.yml
@ -27,6 +27,20 @@ platform:
|
|||||||
arch: amd64
|
arch: amd64
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: binary
|
||||||
|
image: dart:stable
|
||||||
|
commands:
|
||||||
|
- apt-get -qq update && apt-get install -yqq --no-install-recommends make
|
||||||
|
- make build
|
||||||
|
|
||||||
|
- name: verify
|
||||||
|
image: dart:stable
|
||||||
|
commands:
|
||||||
|
- src/build/linkcheck/linkcheck --help
|
||||||
|
- src/build/linkcheck/linkcheck --version
|
||||||
|
depends_on:
|
||||||
|
- binary
|
||||||
|
|
||||||
- name: dryrun
|
- name: dryrun
|
||||||
image: thegeeklab/drone-docker-buildx:20
|
image: thegeeklab/drone-docker-buildx:20
|
||||||
settings:
|
settings:
|
||||||
@ -42,6 +56,8 @@ steps:
|
|||||||
when:
|
when:
|
||||||
ref:
|
ref:
|
||||||
- refs/pull/**
|
- refs/pull/**
|
||||||
|
depends_on:
|
||||||
|
- verify
|
||||||
|
|
||||||
- name: tags
|
- name: tags
|
||||||
image: thegeeklab/docker-autotag
|
image: thegeeklab/docker-autotag
|
||||||
@ -153,7 +169,7 @@ steps:
|
|||||||
DOCKER_USER:
|
DOCKER_USER:
|
||||||
from_secret: docker_username
|
from_secret: docker_username
|
||||||
PUSHRM_FILE: README.md
|
PUSHRM_FILE: README.md
|
||||||
PUSHRM_SHORT: Custom image for broken-link-checker
|
PUSHRM_SHORT: Custom image for linkcheck
|
||||||
PUSHRM_TARGET: thegeeklab/${DRONE_REPO_NAME}
|
PUSHRM_TARGET: thegeeklab/${DRONE_REPO_NAME}
|
||||||
when:
|
when:
|
||||||
status:
|
status:
|
||||||
@ -201,6 +217,6 @@ depends_on:
|
|||||||
|
|
||||||
---
|
---
|
||||||
kind: signature
|
kind: signature
|
||||||
hmac: 146d9e41ffdf9ebeae30b044503608af4a872f420cf7f799e70d4ab3a50f4f77
|
hmac: c395bc7653458c3fa8c3bd62cb9f615d3af8c53e7c929b1ea90b6c3a71738e6e
|
||||||
|
|
||||||
...
|
...
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
CHANGELOG.md
|
CHANGELOG.md
|
||||||
|
/src
|
||||||
|
41
Dockerfile
41
Dockerfile
@ -1,4 +1,4 @@
|
|||||||
FROM node:lts-alpine3.15@sha256:1a9a71ea86aad332aa7740316d4111ee1bd4e890df47d3b5eff3e5bded3b3d10
|
FROM debian:bullseye-slim
|
||||||
|
|
||||||
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>"
|
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>"
|
||||||
LABEL org.opencontainers.image.authors="Robert Kaussow <mail@thegeeklab.de>"
|
LABEL org.opencontainers.image.authors="Robert Kaussow <mail@thegeeklab.de>"
|
||||||
@ -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"
|
LABEL org.opencontainers.image.documentation="https://gitea.rknet.org/docker/link-validator"
|
||||||
|
|
||||||
ARG BUILD_VERSION
|
ARG BUILD_VERSION
|
||||||
# renovate: datasource=npm depName=broken-link-checker
|
ARG WAIT_FOR_VERSION
|
||||||
ENV BLC_VERSION="${BUILD_VERSION:-0.7.8}"
|
ARG CONTAINER_LIBRARY
|
||||||
|
|
||||||
|
|
||||||
# renovate: datasource=github-releases depName=caddyserver/caddy
|
# 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 \
|
ENV LINK_VALIDATOR_BASE_DIR=/drone/src \
|
||||||
LINK_VALIDATOR_SERVER_PORT=80 \
|
LINK_VALIDATOR_SERVER_PORT=8000
|
||||||
FORCE_COLOR=true \
|
|
||||||
NPM_CONFIG_LOGLEVEL=error
|
|
||||||
|
|
||||||
COPY overlay/ /
|
COPY overlay/ /
|
||||||
|
|
||||||
RUN echo "Installing requirements ..." && \
|
RUN apt-get update && apt-get install -y curl bash ncat media-types && \
|
||||||
apk --update add --virtual .build-deps curl && \
|
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 "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 && \
|
chmod 755 /usr/local/bin/caddy && \
|
||||||
BLC_VERSION="${BLC_VERSION##v}" && \
|
chmod 755 /usr/local/bin/wait-for && \
|
||||||
BLC_MAJOR="${BLC_VERSION%%.*}" && \
|
rm -rf /var/lib/apt/lists/* && \
|
||||||
if [ -z "${BLC_MAJOR//[0-9]}" ] && [ -n "$BLC_MAJOR" ]; then \
|
rm -rf /tmp/* && \
|
||||||
echo "Installing link-checker version '$BLC_VERSION' ..." && \
|
rm -rf /root/.cache/
|
||||||
npm install -g broken-link-checker@"$BLC_VERSION"; \
|
|
||||||
else \
|
ADD src/build/linkcheck/linkcheck /usr/local/bin/linkcheck
|
||||||
echo "Installing latest link-checker ..." && \
|
|
||||||
npm install -g broken-link-checker; \
|
|
||||||
fi && \
|
|
||||||
apk del .build-deps && \
|
|
||||||
rm -rf /var/cache/apk/* && \
|
|
||||||
rm -rf /tmp/*
|
|
||||||
|
|
||||||
USER root
|
USER root
|
||||||
CMD []
|
CMD []
|
||||||
|
29
Makefile
Normal file
29
Makefile
Normal file
@ -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)
|
@ -1,6 +1,6 @@
|
|||||||
# link-validator
|
# 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)
|
[![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)
|
[![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)
|
[![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)
|
[![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
|
## Usage
|
||||||
|
|
||||||
```Shell
|
```Shell
|
||||||
docker run -v $(pwd)/public:/drone/src link-validator
|
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.
|
# ... 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
|
## Environment variables
|
||||||
|
@ -1,5 +1,16 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
caddy file-server --root "$LINK_VALIDATOR_BASE_DIR" --listen "127.0.0.1:$LINK_VALIDATOR_SERVER_PORT" &> /dev/null &
|
# shellcheck disable=SC1091
|
||||||
exec /usr/local/bin/broken-link-checker "$@" http://localhost:"$LINK_VALIDATOR_SERVER_PORT"
|
. /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"
|
||||||
|
Reference in New Issue
Block a user