From ebba9f900af18c8c97e2a569e13670d98e8d658d Mon Sep 17 00:00:00 2001 From: David de Boer Date: Wed, 26 Jun 2024 11:21:06 +0200 Subject: [PATCH] feat: Publish Docker image --- .github/workflows/docker.yml | 41 ++++++++++++++++++++++++++++++++++++ README.md | 18 ++++++++++++++-- docker/Dockerfile | 8 +++++++ docker/entrypoint.sh | 7 ++++++ 4 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/docker.yml create mode 100644 docker/Dockerfile create mode 100755 docker/entrypoint.sh diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..77119c4 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,41 @@ +name: Publish Docker image + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + push_to_registry: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + attestations: write + id-token: write + steps: + - uses: actions/checkout@v4 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/metadata-action@v5 + id: meta + with: + images: ghcr.io/${{ github.repository }} + - uses: docker/build-push-action@v5 + id: push + with: + context: . + file: docker/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.output.labels }} + - uses: actions/attest-build-provenance@v1 + with: + subject-name: ghcr.io/${{ github.repository }} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true diff --git a/README.md b/README.md index 22f0c40..6861af0 100644 --- a/README.md +++ b/README.md @@ -34,12 +34,24 @@ so users will not be locked into a proprietary tool or technology. ## Usage -To get started with LD Workbench, first install [NodeJS](https://nodejs.org), then run: +To get started with LD Workbench, you can either use the NPM package or a Docker image. + +To use the NPM package, install [Node.js](https://nodejs.org), then run: ```sh npx @netwerk-digitaal-erfgoed/ld-workbench@latest --init ```` +Alternatively, to run the Docker image, +first create a directory to store your pipeline configurations, +then run the Docker image (mounting the `pipelines/` directory with `-v` and using `-t` for colorful console output): + +```sh +mkdir pipelines +docker run -t -v $(pwd)/pipelines:/pipelines ghcr.io/netwerk-digitaal-erfgoed/ld-workbench:latest +``` + + This creates an example LD Workbench pipeline in the `pipelines/configurations/example` directory and runs that pipeline right away. The output is written to `pipelines/data`. @@ -61,7 +73,9 @@ You can find more examples in the [ld-workbench-configuration](https://github.co #### Iterator -Each stage has a single iterator. The iterator SPARQL SELECT query must return a `$this` binding for each URI that will be passed to the generator(s). +Each stage has a single iterator. +The iterator selects URIs from a dataset that match certain criteria. +The iterator SPARQL SELECT query must return a `$this` binding for each URI that will be passed to the generator(s). The query can be specified either inline: diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..bf1f7a8 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,8 @@ +FROM node:lts-alpine AS build + +RUN npm install -g @netwerk-digitaal-erfgoed/ld-workbench@latest \ + && npm cache clean --force + +COPY docker/entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] +USER node diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 0000000..bc237e4 --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ -d "/pipelines/configurations/example" ]; then + ld-workbench $@ +else + ld-workbench --init +fi