├── .env.sample ├── .github ├── dependabot.yml └── workflows │ ├── check_upstream.yml │ └── ci.yml ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── runstr.sh ├── structurizr-cli-latest.txt └── tests ├── doc ├── adr │ ├── 0001-record-architecture-decisions.md │ └── 0002-implement-as-unix-shell-scripts.md └── docs │ └── example.md └── workspace.dsl /.env.sample: -------------------------------------------------------------------------------- 1 | STR_ID= 2 | STR_API_KEY= 3 | STR_API_SECRET= 4 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | # Maintain dependencies for GitHub Actions 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "weekly" 8 | 9 | - package-ecosystem: docker 10 | directory: / 11 | schedule: 12 | interval: daily 13 | -------------------------------------------------------------------------------- /.github/workflows/check_upstream.yml: -------------------------------------------------------------------------------- 1 | name: check upstream 2 | on: 3 | schedule: 4 | - cron: '0 10 * * *' 5 | 6 | jobs: 7 | get-version: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Checkout 11 | uses: actions/checkout@v3 12 | 13 | - name: Fetch release version 14 | run: | 15 | curl -sL https://api.github.com/repos/structurizr/cli/releases/latest | \ 16 | jq -e -r ".tag_name" > structurizr-cli-latest.txt 17 | 18 | - name: Check for modified files 19 | id: git-check 20 | run: echo ::set-output name=modified::$([ -z "`git status --porcelain`" ] && echo "false" || echo "true") 21 | 22 | - name: Create Pull Request 23 | if: steps.git-check.outputs.modified == 'true' 24 | uses: peter-evans/create-pull-request@v4.2.3 25 | with: 26 | token: ${{ secrets.GITHUB_TOKEN }} 27 | commit-message: "feat(structurizr-cli): bump version" 28 | title: Update upstream version 29 | body: | 30 | - Dependency updates 31 | branch-suffix: random 32 | base: main 33 | committer: GitHub 34 | author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> 35 | assignees: ${{ github.repository_owner }} 36 | reviewers: ${{ github.repository_owner }} 37 | labels: | 38 | bump_upstream_version 39 | automated_pr 40 | 41 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | on: 3 | push: 4 | tags: 5 | - 'v*' 6 | branches: 7 | - 'create-pull-request/**' 8 | pull_request: 9 | branches: 10 | - main 11 | 12 | jobs: 13 | ci: 14 | runs-on: ubuntu-latest 15 | name: ci 16 | steps: 17 | 18 | - name: Checkout 19 | uses: actions/checkout@v3 20 | 21 | - name: Get shortsha 22 | id: vars 23 | run: | 24 | echo ::set-output name=sha_short::sha-$(git rev-parse --short=7 ${{ github.sha }}) 25 | echo ::set-output name=structurizr_version::$(cat structurizr-cli-latest.txt | sed 's/[^0-9.]*//g') 26 | 27 | - name: Set up Docker Buildx 28 | uses: docker/setup-buildx-action@v2.0.0 29 | 30 | - name: Cache Docker layers 31 | uses: actions/cache@v3.0.11 32 | with: 33 | path: /tmp/.buildx-cache 34 | key: ${{ runner.os }}-buildx-${{ github.sha }} 35 | restore-keys: | 36 | ${{ runner.os }}-buildx- 37 | 38 | - name: Docker meta 39 | id: docker_meta 40 | uses: crazy-max/ghaction-docker-meta@v4.1.1 41 | with: 42 | images: ghcr.io/${{ github.repository }} 43 | tags: | 44 | type=sha 45 | type=ref,event=tag 46 | 47 | - name: Build 48 | uses: docker/build-push-action@v3.2.0 49 | with: 50 | context: . 51 | file: ./Dockerfile 52 | load: true 53 | cache-to: type=local,dest=/tmp/.buildx-cache 54 | cache-from: type=local,src=/tmp/.buildx-cache 55 | tags: ${{ steps.docker_meta.outputs.tags }} 56 | labels: | 57 | ${{ steps.docker_meta.outputs.labels }} 58 | org.opencontainers.image.description=structurizr-cli docker container 59 | org.opencontainers.image.authors=Maksim Milykh aidmax@mail.ru 60 | build-args: | 61 | STRUCTURIZR_VERSION=${{ steps.vars.outputs.structurizr_version }} 62 | 63 | - name: Setting permissions and tags 64 | run: | 65 | chmod +x ./runstr.sh 66 | sed -i 's/docker:latest/docker:${{ steps.vars.outputs.sha_short }}/g' ./runstr.sh 67 | 68 | #TODO: Add tests for other commands 69 | 70 | - name: Checking "push" command 71 | # See https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/ 72 | if: github.actor!= 'dependabot[bot]' 73 | run: | 74 | ./runstr.sh push \ 75 | -id ${{ secrets.STZR_ID }} \ 76 | -key ${{ secrets.STZR_API_KEY }} \ 77 | -secret ${{ secrets.STZR_API_SECRET }} \ 78 | -workspace ./tests/workspace.dsl 79 | 80 | - name: Checking "pull" command 81 | # See https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/ 82 | if: github.actor!= 'dependabot[bot]' 83 | run: | 84 | ./runstr.sh pull \ 85 | -id ${{ secrets.STZR_ID }} \ 86 | -key ${{ secrets.STZR_API_KEY }} \ 87 | -secret ${{ secrets.STZR_API_SECRET }} 88 | 89 | - name: Checking "pull" command verify downloaded workspace files 90 | # See https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/ 91 | if: github.actor!= 'dependabot[bot]' 92 | run: | 93 | files=$(ls ${{ github.workspace }}/*.json 2> /dev/null | wc -l) 94 | if [[ "$files" != 0 ]] 95 | then 96 | echo OK 97 | else 98 | exit 1 99 | fi 100 | 101 | - name: Checking "validate" command 102 | # See https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/ 103 | if: github.actor!= 'dependabot[bot]' 104 | run: | 105 | ./runstr.sh validate \ 106 | -workspace ./tests/workspace.dsl 107 | 108 | - name: Checking "list" command 109 | # See https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/ 110 | if: github.actor!= 'dependabot[bot]' 111 | run: | 112 | ./runstr.sh list \ 113 | -workspace ./tests/workspace.dsl 114 | 115 | - name: Checking "export" command 116 | # See https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/ 117 | if: github.actor!= 'dependabot[bot]' 118 | run: | 119 | for format in plantuml mermaid websequencediagrams dot ilograph json dsl theme 120 | do 121 | ./runstr.sh export -workspace ./tests/workspace.dsl -format $format; 122 | done 123 | 124 | - name: Run Trivy vulnerability scanner 125 | uses: aquasecurity/trivy-action@master 126 | with: 127 | image-ref: 'ghcr.io/${{ github.repository }}:${{ steps.vars.outputs.sha_short }}' 128 | format: 'table' 129 | #FIXME: https://github.com/aquasecurity/trivy-action/issues/91 130 | # exit-code: '1' 131 | ignore-unfixed: true 132 | vuln-type: 'os,library' 133 | severity: 'CRITICAL,HIGH' 134 | 135 | - name: Run shellcheck 136 | uses: ludeeus/action-shellcheck@master 137 | 138 | - name: Login to GitHub Container Registry 139 | if: github.event_name != 'pull_request' 140 | uses: docker/login-action@v2.1.0 141 | with: 142 | registry: ghcr.io 143 | username: ${{ github.repository_owner }} 144 | password: ${{ secrets.CR_PAT }} 145 | 146 | - name: Build and push 147 | uses: docker/build-push-action@v3.2.0 148 | if: github.event_name != 'pull_request' 149 | with: 150 | context: . 151 | file: ./Dockerfile 152 | push: ${{ github.event_name != 'pull_request' }} 153 | cache-from: type=local,src=/tmp/.buildx-cache 154 | cache-to: type=local,dest=/tmp/.buildx-cache 155 | tags: ${{ steps.docker_meta.outputs.tags }} 156 | labels: | 157 | ${{ steps.docker_meta.outputs.labels }} 158 | org.opencontainers.image.description=structurizr-cli docker container 159 | org.opencontainers.image.authors=Maksim Milykh 160 | build-args: | 161 | STRUCTURIZR_VERSION=${{ steps.vars.outputs.structurizr_version }} 162 | 163 | # Disable this due to https://github.com/actions/delete-package-versions/issues/28 164 | # - name: Delete oldest image 165 | # if: github.event_name != 'pull_request' 166 | # uses: actions/delete-package-versions@v1 167 | # with: 168 | # package-name: 'structurizr-cli-docker' 169 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | structurizr-*-*.json 2 | .env 3 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM eclipse-temurin:19-alpine 2 | 3 | ARG STRUCTURIZR_VERSION 4 | 5 | # Create app directory 6 | WORKDIR /root/structurizr 7 | 8 | # Install structurizr 9 | RUN set -e; \ 10 | apk add --no-cache \ 11 | bash \ 12 | && wget https://github.com/structurizr/cli/releases/download/v${STRUCTURIZR_VERSION}/structurizr-cli-${STRUCTURIZR_VERSION}.zip && \ 13 | unzip structurizr-cli-${STRUCTURIZR_VERSION}.zip && \ 14 | ln -s structurizr-cli-${STRUCTURIZR_VERSION}.jar structurizr-cli.jar && \ 15 | rm structurizr-cli-${STRUCTURIZR_VERSION}.zip 16 | 17 | ENTRYPOINT [ "bash", "/root/structurizr/structurizr.sh" ] 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Maksim Milykh 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # structurizr-cli-docker 2 | 3 | This docker container allows you to run [structurizr-cli](https://github.com/structurizr/cli), a command line utility for [Structurizr](https://structurizr.com/) that lets you create software architecture models based upon the [C4 model](https://c4model.com/) using a textual [domain specific language (DSL)](https://github.com/structurizr/dsl). 4 | 5 | ## Usage 6 | 7 | ```bash 8 | # Make alias for cli command 9 | alias str="docker run --rm -v '${PWD}':/root/data -w /root/data ghcr.io/aidmax/structurizr-cli-docker" 10 | 11 | # Load your credentials (see example in .env.sample) 12 | source .env 13 | 14 | # Check syntax 15 | str validate -workspace workspace.dsl 16 | 17 | # Push diagrams to structurizr web service 18 | str push -id $STR_ID -key $STR_API_KEY -secret $STR_API_SECRET -workspace your_workspace_file.dsl 19 | ``` 20 | 21 | ## GitHub Action 22 | 23 | There is also a GitHub Action based on this repo you can use for automation. 24 | 25 | Refer to [GitHub Marketplace](https://github.com/marketplace/actions/structurizr-cli-action) or [repo](https://github.com/aidmax/structurizr-cli-action) 26 | 27 | ## License 28 | 29 | The Dockerfile and documentation in this project are released under the [MIT](license). 30 | 31 | ## Credits 32 | 33 | The Dockerfile and documentation have been created by [Maksim Milykh](https://github.com/aidmax). 34 | -------------------------------------------------------------------------------- /runstr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker run --rm \ 4 | -v "${PWD}":/root/data \ 5 | -w /root/data \ 6 | ghcr.io/aidmax/structurizr-cli-docker:latest "$@" 7 | -------------------------------------------------------------------------------- /structurizr-cli-latest.txt: -------------------------------------------------------------------------------- 1 | v2024.02.22 2 | -------------------------------------------------------------------------------- /tests/doc/adr/0001-record-architecture-decisions.md: -------------------------------------------------------------------------------- 1 | # 1. Record architecture decisions 2 | 3 | Date: 2020-11-25 4 | 5 | ## Status 6 | 7 | Accepted 8 | 9 | ## Context 10 | 11 | We need to record the architectural decisions made on this project. 12 | 13 | ## Decision 14 | 15 | We will use Architecture Decision Records, as [described by Michael Nygard](http://thinkrelevance.com/blog/2011/11/15/documenting-architecture-decisions). 16 | 17 | ## Consequences 18 | 19 | See Michael Nygard's article, linked above. For a lightweight ADR toolset, see Nat Pryce's [adr-tools](https://github.com/npryce/adr-tools). 20 | -------------------------------------------------------------------------------- /tests/doc/adr/0002-implement-as-unix-shell-scripts.md: -------------------------------------------------------------------------------- 1 | # 2. Implement as Unix shell scripts 2 | 3 | Date: 2020-11-25 4 | 5 | ## Status 6 | 7 | Accepted 8 | 9 | ## Context 10 | 11 | The issue motivating this decision, and any context that influences or constrains the decision. 12 | 13 | ## Decision 14 | 15 | The change that we're proposing or have agreed to implement. 16 | 17 | ## Consequences 18 | 19 | What becomes easier or more difficult to do and any risks introduced by the change that will need to be mitigated. 20 | -------------------------------------------------------------------------------- /tests/doc/docs/example.md: -------------------------------------------------------------------------------- 1 | ## Section Title 2 | -------------------------------------------------------------------------------- /tests/workspace.dsl: -------------------------------------------------------------------------------- 1 | workspace "Getting Started" "This is a model of my software system." { 2 | 3 | !adrs doc/adr 4 | !docs doc/docs 5 | 6 | model { 7 | user = person "User" "A user of my software system." 8 | softwareSystem = softwareSystem "Software System" "My software system." 9 | 10 | user -> softwareSystem "Uses" 11 | } 12 | 13 | views { 14 | systemContext softwareSystem "SystemContext" "An example of a System Context diagram." { 15 | include * 16 | autoLayout 17 | } 18 | 19 | styles { 20 | element "Software System" { 21 | background #1168bd 22 | color #ffffff 23 | } 24 | element "Person" { 25 | shape person 26 | background #08427b 27 | color #ffffff 28 | } 29 | } 30 | } 31 | 32 | } 33 | --------------------------------------------------------------------------------