Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alpine for docker image #1074

Merged
merged 14 commits into from
May 22, 2023
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ updates:
schedule:
interval: daily
open-pull-requests-limit: 10

- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
open-pull-requests-limit: 10
43 changes: 38 additions & 5 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@ env:
IMAGE_NAME: lycheeverse/lychee
DOCKER_PLATFORMS: linux/amd64,linux/arm64/v8
DOCKERFILE: Dockerfile-CI.Dockerfile
DOCKERFILE_ALPINE: Dockerfile-CI.alpine.Dockerfile

jobs:
build:
runs-on: ubuntu-latest
if: github.repository_owner == 'lycheeverse' &&
github.actor != 'dependabot[bot]' &&
github.actor != 'dependabot[bot]' &&
( github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login )
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Docker meta
- name: Docker meta (debian)
id: meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
Expand All @@ -49,6 +50,28 @@ jobs:
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}

- name: Docker meta (alpine)
id: meta-alpine
uses: docker/metadata-action@v4
with:
# A global suffix for each generated tag
flavor: |
suffix=-alpine
# list of Docker images to use as base name for tags
images: |
${{ env.IMAGE_NAME }}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

Expand All @@ -61,8 +84,8 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Push Image
uses: docker/build-push-action@v3
- name: Push Image (debian)
uses: docker/build-push-action@v4
with:
context: .
file: ${{ env.DOCKERFILE }}
Expand All @@ -71,6 +94,16 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Push Image (alpine)
uses: docker/build-push-action@v4
with:
context: .
file: ${{ env.DOCKERFILE_ALPINE }}
platforms: ${{ env.DOCKER_PLATFORMS }}
push: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }}
tags: ${{ steps.meta-alpine.outputs.tags }}
labels: ${{ steps.meta-alpine.outputs.labels }}

- name: Update DockerHub description
uses: peter-evans/dockerhub-description@v3
with:
Expand Down
28 changes: 28 additions & 0 deletions Dockerfile-CI.alpine.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM alpine:latest as builder
WORKDIR /builder

RUN apk update \
&& apk add --no-cache ca-certificates jq wget \
&& case $(arch) in \
"x86_64") \
wget -4 -q -O - "$(wget -4 -q -O- https://api.github.com/repos/lycheeverse/lychee/releases/latest \
| jq -r '.assets[].browser_download_url' \
| grep x86_64-unknown-linux-musl)" | tar -xz lychee \
;; \
"aarch64") \
wget -4 -q -O - "$(wget -4 -q -O- https://api.github.com/repos/lycheeverse/lychee/releases/latest \
| jq -r '.assets[].browser_download_url' \
| grep arm-unknown-linux-musleabihf)" | tar -xz lychee \
;; \
esac \
&& chmod +x lychee

FROM alpine:latest
RUN apk add --no-cache ca-certificates tzdata \
&& addgroup -S lychee \
&& adduser -D -G lychee -S lychee

COPY --from=builder /builder/lychee /usr/local/bin/lychee
# Run as non-root user
USER lychee
ENTRYPOINT [ "/usr/local/bin/lychee" ]
47 changes: 34 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ This comparison is made on a best-effort basis. Please create a PR to fix
outdated information.

| | lychee | [awesome_bot] | [muffet] | [broken-link-checker] | [linkinator] | [linkchecker] | [markdown-link-check] | [fink] |
| -------------------- | ------- | ------------- | -------- | --------------------- | ------------ | -------------------- | --------------------- | ------ |
|----------------------|---------|---------------|----------|-----------------------|--------------|----------------------|-----------------------|--------|
| Language | Rust | Ruby | Go | JS | TypeScript | Python | JS | PHP |
| Async/Parallel | ![yes] | ![yes] | ![yes] | ![yes] | ![yes] | ![yes] | ![yes] | ![yes] |
| JSON output | ![yes] | ![no] | ![yes] | ![yes] | ![yes] | ![maybe]<sup>1</sup> | ![yes] | ![yes] |
Expand Down Expand Up @@ -188,28 +188,49 @@ but in case you need dedicated support for a new file format, please consider cr
### Docker Usage

Here's how to mount a local directory into the container and check some input
with lychee. The `--init` parameter is passed so that lychee can be stopped
from the terminal. We also pass `-it` to start an interactive terminal, which
is required to show the progress bar.
with lychee.

- The `--init` parameter is passed so that lychee can be stopped from the terminal.
- We also pass `-it` to start an interactive terminal, which is required to show the progress bar.
- The `--rm` removes not used anymore container from the host after the run (self-cleanup).
- The `-w /input` points to `/input` as the default workspace
- The `-v $(pwd):/input` does local volume mounting to the container for lychee access.

> By default a Debian-based docker image is used. If you want to run an Alpine-based image, use the `latest-alpine` tag.
mre marked this conversation as resolved.
Show resolved Hide resolved
> For example, `lycheeverse/lychee:latest-alpine`

#### Linux/macOS shell command

```sh
docker run --init -it -v `pwd`:/input lycheeverse/lychee /input/README.md
docker run --init -it --rm -w /input -v $(pwd):/input lycheeverse/lychee README.md
```

#### Windows PowerShell command

```powershell
docker run --init -it --rm -w /input -v ${PWD}:/input lycheeverse/lychee README.md
```

### GitHub Token

To avoid getting rate-limited while checking GitHub links, you can optionally
set an environment variable with your Github token like so `GITHUB_TOKEN=xxxx`,
set an environment variable with your GitHub token like so `GITHUB_TOKEN=xxxx`,
or use the `--github-token` CLI option. It can also be set in the config file.
[Here is an example config file][config file].

The token can be generated in your
[GitHub account settings page](https://github.com/settings/tokens). A personal
token with no extra permissions is enough to be able to check public repos links.
The token can be generated on your [GitHub account settings page](https://github.com/settings/tokens).
A personal access token with no extra permissions is enough to be able to check public repos links.
mre marked this conversation as resolved.
Show resolved Hide resolved

For more scalable organization-wide scenarios you can consider a [GitHub App][github-app-overview].
It has a higher rate limit than personal access tokens but requires additional configuration steps on your GitHub workflow.
Please follow the [GitHub App Setup][github-app-setup] example.

[github-app-overview]: https://docs.github.com/en/apps/overview
[github-app-setup]: https://github.com/github/combine-prs/blob/main/docs/github-app-setup.md#github-app-setup

### Commandline Parameters

There is an extensive list of commandline parameters to customize the behavior.
There is an extensive list of command line parameters to customize the behavior.
See below for a full list.

```text
Expand Down Expand Up @@ -472,7 +493,7 @@ which includes usage instructions.
## Contributing to lychee

We'd be thankful for any contribution. \
We try to keep the issue-tracker up-to-date so you can quickly find a task to work on.
We try to keep the issue tracker up-to-date so you can quickly find a task to work on.

Try one of these links to get started:

Expand All @@ -487,7 +508,7 @@ Lychee makes heavy use of async code to be resource-friendly while still being
performant. Async code can be difficult to troubleshoot with most tools,
however. Therefore we provide experimental support for
[tokio-console](https://github.com/tokio-rs/console). It provides a top(1)-like
overview for async tasks!
an overview for async tasks!
mre marked this conversation as resolved.
Show resolved Hide resolved

If you want to give it a spin, download and start the console:

Expand Down Expand Up @@ -532,7 +553,7 @@ If you are using lychee for your project, **please add it here**.
## Credits

The first prototype of lychee was built in [episode 10 of Hello
Rust](https://hello-rust.show/10/). Thanks to all Github- and Patreon sponsors
Rust](https://hello-rust.show/10/). Thanks to all GitHub and Patreon sponsors
for supporting the development since the beginning. Also, thanks to all the
great contributors who have since made this project more mature.

Expand Down