diff --git a/.dockerignore b/.dockerignore index dd59c3f5..a16bb106 100644 --- a/.dockerignore +++ b/.dockerignore @@ -10,4 +10,5 @@ Dockerfile .dockerignore -docker-compose.yml \ No newline at end of file +docker-compose.yml +README.md \ No newline at end of file diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 1492b3d7..83a6f984 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -2,13 +2,11 @@ name: Docker on: push: - # Publish `master` as Docker `latest` image. branches: + # Publish `master` as Docker `latest` image. - master - - # Publish `v1.2.3` tags as releases. - tags: - - v* + # Publish `nightly` as Docker `nightly` image. + - develop # Run tests for all PRs to master and develop. pull_request: @@ -30,40 +28,21 @@ jobs: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Get release version + run: | + RELEASE_VERSION=$([ "${{ github.ref_name }}" = "master" ] && echo "latest" || echo "nightly") + echo "RELEASE_VERSION=${RELEASE_VERSION}" >> "${GITHUB_ENV}" - uses: docker/metadata-action@v5 - if: github.ref_type == 'tag' id: meta with: images: ghcr.io/${{ github.repository }} - # this will generate tags in the following format: - # - # latest - # 1.2.3 tags: | - type=raw,value=latest - type=semver,pattern={{version}} + type=raw,value=${{ env.RELEASE_VERSION }} - uses: docker/build-push-action@v5 - if: github.ref_type == 'tag' with: context: . target: mermaid - push: true + push: ${{ github.event_name == 'push' }} pull: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - - uses: docker/metadata-action@v5 - if: github.ref_type == 'branch' - id: meta-nightly - with: - images: ghcr.io/${{ github.repository }} - tags: | - type=raw,value=nightly - - uses: docker/build-push-action@v5 - if: github.ref_type == 'branch' - with: - context: . - target: mermaid - push: ${{ github.event_name != 'pull_request' }} - pull: true - tags: ${{ steps.meta-nightly.outputs.tags }} - labels: ${{ steps.meta-nightly.outputs.labels }} diff --git a/README.md b/README.md index cf042bd3..5c18f655 100644 --- a/README.md +++ b/README.md @@ -29,12 +29,12 @@ docker run --platform linux/amd64 --publish 8000:8080 ghcr.io/mermaid-js/mermaid ### To configure renderer URL -When building, Set the Environment variable MERMAID_RENDERER_URL to the rendering service. +When building set the MERMAID_RENDERER_URL build argument to the rendering service. Default is `https://mermaid.ink` ### To configure Kroki Instance URL -When building, Set the Environment variable MERMAID_KROKI_RENDERER_URL to your Kroki instance. +When building set the MERMAID_KROKI_RENDERER_URL build argument to your Kroki instance. Default is `https://kroki.io` ### Development @@ -45,6 +45,28 @@ docker compose up --build Then open http://localhost:3000 +### Building and running images locally + +#### Build + +```bash +docker build -t mermaid-js/mermaid-live-editor . +``` + +#### Run + +```bash +docker run --detach --name mermaid-live-editor --publish 8080:8080 mermaid-js/mermaid-live-editor +``` + +Visit: + +#### Stop + +```bash +docker stop mermaid-live-editor +``` + ## Setup Below link will help you making a copy of the repository in your local system.