From d8f89b7274ca546b4abbf9f6ba728d90bc5938ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roswita=20Tsch=C3=BCmperlin?= <108136714+tschumpr@users.noreply.github.com> Date: Mon, 15 Jan 2024 17:03:32 +0100 Subject: [PATCH] Github Action to create Docker image (#392) * Add action to build image on release Co-authored-by: Matthias Mohr --- .gitattributes | 2 ++ .github/workflows/publish.yml | 62 +++++++++++++++++++++++++++++++++++ README.md | 15 +++++++++ 3 files changed, 79 insertions(+) create mode 100644 .gitattributes create mode 100644 .github/workflows/publish.yml diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..79f1111aa --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# *nix shell scripts always use LF (see .editorconfig) +*.sh eol=lf \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..334c242de --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,62 @@ +name: Publish + +on: + release: + types: [released] + workflow_dispatch: + inputs: + TAG_NAME: + description: "Tag name" + required: true + +env: + REGISTRY: ghcr.io + TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }} + +jobs: + retag-docker-image: + runs-on: ubuntu-latest + name: Push updated Docker image + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set environment variables + run: | + echo VERSION=${TAG_NAME#v} >> $GITHUB_ENV + echo IMAGE_NAME=$REGISTRY/$(echo ${GITHUB_REPOSITORY,,}) >> $GITHUB_ENV + echo COMMITED_AT=$(git show -s --format=%cI `git rev-parse HEAD`) >> $GITHUB_ENV + echo REVISION=$(git rev-parse --short HEAD) >> $GITHUB_ENV + + - name: Collect Docker image metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGE_NAME }} + labels: | + org.opencontainers.image.created=${{ env.COMMITED_AT }} + org.opencontainers.image.version=v${{ env.VERSION }} + org.opencontainers.image.maintainer=$({github.repository_owner}) + tags: | + type=semver,pattern={{version}},value=v${{ env.VERSION }} + + - name: Log in to the GitHub container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + build-args: | + VERSION=${{ env.VERSION }} + REVISION=${{ env.REVISION }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:edge + cache-to: type=inline diff --git a/README.md b/README.md index 60d6af792..a2165e9ef 100644 --- a/README.md +++ b/README.md @@ -242,6 +242,8 @@ STAC Browser supports some non-standardized extensions to the STAC specification ## Docker +### Create a custom image + Building the Dockerfile without changing any build options: ```bash @@ -285,6 +287,19 @@ If you want to pass all the other arguments to `npm run build` directly, you can STAC browser is now available at `http://localhost:8080/browser` +### Use an existing image + +You can add an existing image from [Packages](https://github.com/radiantearth/stac-browser/pkgs/container/stac-browser) to your docker-compose.yml: +``` +services: + stac-browser: + image: ghcr.io/radiantearth/stac-browser:latest + ports: + - 8080:8080 + environment: + SB_catalogUrl: "https://localhost:7188" +``` + ## Contributing We are happy to review and accept Pull Requests.