├── .ci └── tests │ ├── basic.bats │ ├── expect │ └── attach.exp │ └── stubs │ └── python ├── .deepsource.toml ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ └── ci.yml ├── .gitignore ├── ENV.example ├── LICENSE ├── README.md ├── RELEASE_NOTES.md └── terminusdb-container /.ci/tests/basic.bats: -------------------------------------------------------------------------------- 1 | set -o allexport 2 | 3 | # SET TEST ENV 4 | TERMINUSDB_IGNORE_ENV=true 5 | TERMINUSDB_AUTOLOGIN_ENABLED=false 6 | TERMINUSDB_PORT=56363 7 | TERMINUSDB_CONTAINER="terminusdb-server-bats-test" 8 | TERMINUSDB_STORAGE=terminusdb-server-bats-test 9 | 10 | if [[ -n "$TERMINUSDB_LOCAL" ]]; then 11 | mkdir -p "$TERMINUSDB_LOCAL" 12 | fi 13 | 14 | # LOAD QUICKSTART ENV 15 | # shellcheck disable=SC1091 16 | # shellcheck source=$(pwd)/terminusdb-container 17 | source "$(pwd)/terminusdb-container" nop 18 | 19 | _check_if_docker_is_in_path 20 | 21 | set +o allexport 22 | 23 | PATH="${BATS_TEST_DIRNAME}/stubs:$PATH" 24 | 25 | yes_container() { 26 | yes | container $@ 27 | } 28 | 29 | container() { 30 | "${BATS_TEST_DIRNAME}/../../terminusdb-container" "${@}" 31 | } 32 | 33 | inspect() { 34 | [[ $($TERMINUSDB_QUICKSTART_DOCKER inspect -f '{{.State.Running}}' "${TERMINUSDB_QUICKSTART_CONTAINER}") == "true" ]] 35 | } 36 | 37 | inspect_volume() { 38 | $TERMINUSDB_QUICKSTART_DOCKER volume inspect -f '{{.Name}}' "${TERMINUSDB_QUICKSTART_STORAGE}" 39 | } 40 | 41 | 42 | @test "quickstart cli" { 43 | run container run 44 | run container cli 45 | [[ "${status}" == 0 ]] 46 | run container stop 47 | } 48 | 49 | @test "quickstart run" { 50 | run container run 51 | [[ "${status}" == 0 ]] 52 | run inspect 53 | [[ "${status}" == 0 ]] 54 | } 55 | 56 | @test "docker volume exists" { 57 | run inspect_volume 58 | [[ "${status}" == 0 ]] 59 | } 60 | 61 | @test "quickstart help" { 62 | run container help 63 | [[ "${status}" == 0 ]] 64 | } 65 | 66 | @test "quickstart attach" { 67 | command -v expect || skip 68 | run expect "${BATS_TEST_DIRNAME}/expect/attach.exp" 69 | [[ "${status}" == 0 ]] 70 | } 71 | 72 | @test "quickstart stop" { 73 | run container stop >&3 74 | [[ "${status}" == "0" ]] 75 | run inspect 76 | [[ "${status}" != "0" ]] 77 | } 78 | 79 | @test "terminusdb server tests" { 80 | $TERMINUSDB_QUICKSTART_DOCKER run --rm "$TERMINUSDB_QUICKSTART_REPOSITORY:$TERMINUSDB_QUICKSTART_TAG" bash -c "./terminusdb store init --key root && ./terminusdb test" 81 | } 82 | 83 | @test "quickstart rm" { 84 | run yes_container rm >&3 85 | [[ "${status}" == 0 ]] 86 | run inspect_volume 87 | [[ "${status}" != 0 ]] 88 | } 89 | -------------------------------------------------------------------------------- /.ci/tests/expect/attach.exp: -------------------------------------------------------------------------------- 1 | spawn ./terminusdb-container attach 2 | expect -exact "\r 3 | Ctrl+p Ctrl+q to detach\r 4 | \r 5 | " 6 | send -- "\r" 7 | expect -exact "\r| \r 8 | | " 9 | send -- "" 10 | -------------------------------------------------------------------------------- /.ci/tests/stubs/python: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo python 3 | -------------------------------------------------------------------------------- /.deepsource.toml: -------------------------------------------------------------------------------- 1 | version = 1 2 | 3 | [[analyzers]] 4 | name = "shell" 5 | enabled = true 6 | 7 | [[analyzers]] 8 | name = "secrets" 9 | enabled = true -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **System information (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Version [e.g. 22] 29 | - How did you run terminus-quickstart? 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | pull_request: 6 | 7 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 8 | jobs: 9 | # This workflow contains a single job called "build" 10 | build: 11 | # The type of runner that the job will run on 12 | runs-on: ubuntu-latest 13 | 14 | # Steps represent a sequence of tasks that will be executed as part of the job 15 | steps: 16 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 17 | - uses: actions/checkout@v2 18 | 19 | - name: Install expect 20 | run: sudo apt-get install expect 21 | 22 | - name: Install bats for testing 23 | run: sudo npm install -g bats 24 | 25 | - name: Run shellcheck 26 | run: shellcheck ./terminusdb-container 27 | 28 | - name: Run tests with bats 29 | run: bats .ci/tests/basic.bats 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ENV 2 | .ENV.swp 3 | local_file 4 | ENV.old 5 | _bats_log 6 | .ci/build 7 | package-lock.json 8 | -------------------------------------------------------------------------------- /ENV.example: -------------------------------------------------------------------------------- 1 | # shellcheck shell=sh 2 | # shellcheck disable=SC2034 3 | 4 | # 5 | # ENVIRONMENT 6 | # 7 | # To persist environment settings copy this file to ENV 8 | # 9 | 10 | # Docker command 11 | #TERMINUSDB_DOCKER=sudo docker 12 | 13 | # Container 14 | #TERMINUSDB_CONTAINER=terminusdb-server 15 | #TERMINUSDB_REPOSITORY=terminusdb/terminusdb-server 16 | #TERMINUSDB_NETWORK=bridge 17 | #TERMINUSDB_LABEL_FILE=labels 18 | 19 | # Version 20 | #TERMINUSDB_TAG=dev 21 | 22 | # Name of Docker Storage Volume 23 | #TERMINUSDB_STORAGE=terminusdb_storage_local 24 | 25 | # Container Port to Publish 26 | #TERMINUSDB_PORT=6363 27 | 28 | # Local Directory to Mount inside Container 29 | #TERMINUSDB_LOCAL=/home/username/localfiles 30 | 31 | # URL To TermiunusDB Console 32 | #TERMINUSDB_CONSOLE_BASE_URL=//127.0.0.1:3005 33 | 34 | # Server 35 | #TERMINUSDB_PASS=root 36 | #TERMINUSDB_SERVER_IP=127.0.0.1 37 | #TERMINUSDB_JWT_ENABLED=true 38 | #TERMINUSDB_JWKS_ENDPOINT=http://example.com/jwks.json 39 | #TERMINUSDB_JWT_AGENT_NAME_PROPERTY=preferred_username 40 | #TERMINUSDB_INSECURE_USER_HEADER=X-Forwarded-User 41 | #TERMINUSDB_INSECURE_USER_HEADER_ENABLED=true 42 | 43 | 44 | # Dashboard 45 | #TERMINUSDB_DASHBOARD_LOCAL_PATH=/home/user/to/the/index/folder/of/dashboard 46 | 47 | # vim:ft=sh 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![TerminusDB Bootstrap](https://assets.terminusdb.com/readmes/terminusdb-bootstrap/header.gif)][terminusdb] 2 | 3 | --- 4 | 5 | # Deprecation Notice 6 | 7 | The preferred method of running TerminusDB locally is by using `docker compose`. The Docker image can be used to run TerminusDB 8 | on servers whereas the docker compose is the preferred method of running TerminusDB and its TerminusCMS components locally. 9 | See the main [TerminusDB repository](https://github.com/terminusdb/terminusdb) and our [documentation](https://terminusdb.com/docs/) for more information. 10 | 11 | [![Discord](https://img.shields.io/discord/689805612053168129?label=Discord&logo=Discord&style=plastic)](https://discord.gg/yTJKAma) 12 | [![Reddit](https://img.shields.io/reddit/subreddit-subscribers/TerminusDB?style=social)](https://www.reddit.com/r/TerminusDB/) 13 | [![Twitter](https://img.shields.io/twitter/follow/terminusdb?color=skyblue&label=Follow%20on%20Twitter&logo=twitter&style=flat)](https://twitter.com/TerminusDB) 14 | 15 | [![build status](https://img.shields.io/github/workflow/status/terminusdb/terminusdb-bootstrap/CI?logo=github)](https://github.com/terminusdb/terminusdb-bootstrap/actions) 16 | [![license](https://img.shields.io/github/license/terminusdb/terminusdb-bootstrap?color=pink&logo=apache)](https://github.com/terminusdb/terminusdb-bootstrap/blob/main/LICENSE) 17 | 18 | > Script for running TerminusDB with Docker. 19 | 20 | [**TerminusDB**][terminusdb] is an [open-source][terminusdb-repo] graph database 21 | and document store. It allows you to link JSON documents in a powerful knowledge 22 | graph all through a simple document API. 23 | 24 | [terminusdb]: https://terminusdb.com/ 25 | [terminusdb-repo]: https://github.com/terminusdb/terminusdb 26 | 27 | In case you don't want to run TerminusDB yourself, try out **TerminusX**, a 28 | hosted data platform, built on TerminusDB, that allows you to build, deploy, 29 | execute, monitor, and share versioned data products. TerminusX is in public beta 30 | and you can [sign up now][dashboard]. 31 | 32 | [dashboard]: https://dashboard.terminusdb.com/ 33 | 34 | ## Table of Contents 35 | 36 | * [Prerequisites](#Prerequisites) 37 | * [Docker](#Docker) 38 | * [Git](#Git) 39 | * [Sudo](#Sudo) 40 | * [Installing](#Installing) 41 | * [Get the repo](#Get-this-repo-cd-to-it) 42 | * [Run the container by using the script](#Run-the-container-by-using-the-script-the-first-time) 43 | * [Using the console](#Using-the-console) 44 | * [To stop, attach, etc, see usage](#To-stop-attach-etc-see-usage) 45 | * [Using The Enviroment](#Using-The-Enviroment) 46 | * [Security](#Security) 47 | * [`ENV` File](#ENV-file) 48 | * [`ENV` Examples](#ENV-Examples) 49 | 50 | ## Prerequisites 51 | 52 | ### Docker 53 | 54 | Since this script uses the TerminusDB Docker container, you need to have Docker 55 | running. 56 | 57 | On Windows and Mac, Docker Desktop can be downloaded here: 58 | https://www.docker.com/products/docker-desktop 59 | 60 | Note that on Windows, the default memory allowed for Docker is 2GB. Since this 61 | is an in-memory database, bigger databases require more memory. Therefore 62 | raise the default allowed memory usage to a higher value in the Docker Desktop 63 | settings. 64 | 65 | On Linux, use your distro's package manager, or find more information here: 66 | https://www.docker.com/products/container-runtime 67 | 68 | ### Git 69 | 70 | This script is distributed via GitHub, so you will need git to clone and update 71 | it, if you don't already have git, you can download it here: 72 | https://git-scm.com/downloads 73 | 74 | Windows users should use the application "Git Bash" for all terminal commands 75 | described below, this application comes with Git for Windows. 76 | 77 | ### Sudo 78 | 79 | Sudo is optional. As letting unprivileged users run docker is insecure, this 80 | script uses sudo by default if it is available. 81 | 82 | Most users will not need to do anything here, sudo is installed by default on 83 | Macs and many populer Linux distros such as Fedora, Red Hat, Debian, Ubuntu and 84 | Mint. Linux users who use minmal distros such as Archlinux, are advised to 85 | install sudo and confugure their sudoers file accordingly. 86 | 87 | Windows users do not need to do anything here. 88 | 89 | ## Installing 90 | 91 | ### Get this repo, cd to it 92 | 93 | ``` 94 | git clone https://github.com/terminusdb/terminusdb-bootstrap 95 | cd terminusdb-bootstrap 96 | ``` 97 | 98 | ### Run the container by using the script (the first time) 99 | 100 | ``` 101 | ./terminusdb-container run 102 | 103 | Unable to find image 'terminusdb/terminusdb-server:latest' locally 104 | latest: Pulling from terminusdb/terminusdb-server 105 | 8f91359f1fff: Pulling fs layer 106 | 939634dec138: Pulling fs layer 107 | f30474226dd6: Pulling fs layer 108 | 32a63113e3ae: Pulling fs layer 109 | ae35de9092ce: Pulling fs layer 110 | 023c02983955: Pulling fs layer 111 | d9fa4a1acf93: Pulling fs layer 112 | [ ... ] 113 | ``` 114 | 115 | #### If you've installed before 116 | 117 | You may need to remove previous volumes or you may encounter bugs or 118 | the old console. 119 | 120 | Warning: This will lead to losing local data. 121 | 122 | ``` 123 | ./terminusdb-container rm 124 | 125 | This will delete storage volume 126 | Are you sure? [y/N] y 127 | ``` 128 | 129 | ### To stop, attach, etc, see usage 130 | ``` 131 | ./terminusdb-container 132 | 133 | USAGE: 134 | terminusdb-container [COMMAND] 135 | 136 | help show usage 137 | run run container 138 | cli use the terminusdb cli 139 | stop stop container 140 | attach attach to prolog shell 141 | exec execute a command inside the container 142 | rm remove volumes 143 | ``` 144 | 145 | That's it! You're ready to go! 146 | 147 | Oh, and flattery motivates us, please give us a star here: 148 | https://github.com/terminusdb/terminusdb 149 | 150 | # Using The Enviroment 151 | 152 | This script is designed to "work out of the box," however, there may be 153 | situations where advanced users want to override some of it's defaults, this is 154 | done by setting enviroment variables. 155 | 156 | ## Security 157 | 158 | To prevent accidental insecure deployments, the Docker container binds to the 159 | IP 127.0.0.1 and therefore the server will only be accessible on the local 160 | machine, and not from any other machine over the network. 161 | 162 | If you would like to deploy to a server, you will need to enable HTTPS by 163 | putting TerminusDB behind a reverse proxy. 164 | 165 | ## `ENV` File 166 | 167 | The script sources a file called `ENV` if it is found in the current directory. 168 | See [`ENV.example`] for examples of the environment variables that can be set. 169 | 170 | [`ENV.example`]: ./ENV.example 171 | 172 | To have environment variables set every time you run `./terminusdb-container`, 173 | follow these steps: 174 | 175 | 1. Copy `ENV.example` to `ENV`. 176 | 2. Edit `ENV`: uncomment the lines you want to change and set the values. 177 | 178 | ## ENV reference 179 | 180 | | ENV name | Default value | Purpose | 181 | |---------------------------------|---------------------------------------------|------------------------------------------| 182 | | TERMINUSDB_DOCKER | sudo docker | Default docker command | 183 | | TERMINUSDB_CONTAINER | terminusdb-server | Name of the running container | 184 | | TERMINUSDB_REPOSITORY | terminusdb/terminusdb-server | Docker image | 185 | | TERMINUSDB_NETWORK | bridge | Docker network mode | 186 | | TERMINUSDB_TAG | The latest version tag of terminusdb-server | TerminusDB docker image version | 187 | | TERMINUSDB_STORAGE | terminusdb_storage_local | Storage volume name | 188 | | TERMINUSDB_PORT | 6363 | Port to run TerminusDB | 189 | | TERMINUSDB_LOCAL | | Local folder to mount inside container | 190 | | TERMINUSDB_SERVER | 127.0.0.1 | Server on which TerminusDB will run | 191 | | TERMINUSDB_PASS | root | Password for accessing TerminusDB | 192 | | TERMINUSDB_DASHBOARD_LOCAL_PATH | "" | Path to a local version of the dashboard | 193 | 194 | ## Examples 195 | 196 | These are examples of environment variables you can set when running 197 | `./terminusdb-container`. 198 | 199 | ### Mount a local directory inside the container 200 | ``` 201 | TERMINUSDB_LOCAL=/path/to/dir ./terminusdb-container [COMMAND] 202 | ``` 203 | 204 | ### Set the Docker Volume name 205 | ``` 206 | TERMINUSDB_STORAGE=terminus_storage_local ./terminusdb-container [COMMAND] 207 | ``` 208 | 209 | ### Using the latest release 210 | ``` 211 | TERMINUSDB_TAG=latest ./terminusdb-container [COMMAND] 212 | ``` 213 | 214 | ### Using the development release 215 | ``` 216 | TERMINUSDB_TAG=dev ./terminusdb-container [COMMAND] 217 | ``` 218 | 219 | ### Using a specific release instead of latest realease 220 | ``` 221 | TERMINUSDB_TAG=v1.1.2 ./terminusdb-container [COMMAND] 222 | ``` 223 | 224 | ### Not using sudo even when sudo is available 225 | ``` 226 | TERMINUSDB_DOCKER=docker ./terminusdb-container [COMMAND] 227 | ``` 228 | 229 | ### Using podman instead of docker command 230 | ``` 231 | TERMINUSDB_DOCKER="podman" ./terminusdb-container [COMMAND] 232 | ``` 233 | 234 | See the source code to find the other environment variables that can be set. 235 | 236 | -------------------------------------------------------------------------------- /RELEASE_NOTES.md: -------------------------------------------------------------------------------- 1 | # TerminusDB Quickstart Version 2.0.1 Release Notes 2 | 3 | ## New 4 | 5 | - Updated version of TerminusDB console. 6 | 7 | See release notes in [TerminusDB Console](https://github.com/terminusdb/terminusdb-console) for details. 8 | 9 | - Added exec feature to run commands inside container. 10 | - Add build and end-to-end tests for TerminusdB console. 11 | - Add improved importing of environment variables in tests. 12 | - run TerminusDB server tests from bats tests. 13 | - run cypress tests in bats 14 | 15 | # TerminusDB Quickstart Version 2.0 Release Notes 16 | 17 | ## New 18 | 19 | # TerminusDB Quickstart 2.0 is updated for use with TerminusDB Server 2.0, see release notes in [TerminusDB Server](https://github.com/terminusdb/terminusdb-server) for details. 20 | 21 | ## Backwards-Incompatible Changes 22 | 23 | There has been a lot of clean up of environment variables, so if you have an old `ENV` file or are setting the variables by some other means, see [ENV.example](ENV.example) to find the correct names 24 | -------------------------------------------------------------------------------- /terminusdb-container: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # CONFIG 5 | # 6 | 7 | # Load ENV file 8 | 9 | if [[ $1 != "nop" && -z "$TERMINUSDB_IGNORE_ENV" && -f ENV ]]; then 10 | set -o allexport 11 | # shellcheck disable=SC1091 12 | # shellcheck source=ENV 13 | source "$(pwd)/ENV" 14 | set +o allexport 15 | fi 16 | 17 | # Container 18 | TERMINUSDB_QUICKSTART_CONTAINER=${TERMINUSDB_CONTAINER:-terminusdb-server} 19 | TERMINUSDB_QUICKSTART_REPOSITORY=${TERMINUSDB_REPOSITORY:-terminusdb.docker.scarf.sh/terminusdb/terminusdb-server} 20 | 21 | # Version 22 | TERMINUSDB_QUICKSTART_TAG=${TERMINUSDB_TAG:-latest} 23 | 24 | # Volumes 25 | TERMINUSDB_QUICKSTART_STORAGE=${TERMINUSDB_STORAGE:-terminusdb_storage} 26 | TERMINUSDB_QUICKSTART_STORAGE_VOLUME=/app/terminusdb/storage 27 | 28 | # Server 29 | TERMINUSDB_QUICKSTART_PORT=${TERMINUSDB_PORT:-6363} 30 | TERMINUSDB_QUICKSTART_PASS=${TERMINUSDB_PASS:-root} 31 | TERMINUSDB_QUICKSTART_AUTOLOGIN=${TERMINUSDB_AUTOLOGIN_ENABLED:-true} 32 | TERMINUSDB_QUICKSTART_JWT_ENABLED=${TERMINUSDB_JWT_ENABLED:-false} 33 | TERMINUSDB_QUICKSTART_JWT_AGENT_NAME_PROPERTY=${TERMINUSDB_JWT_AGENT_NAME_PROPERTY:-''} 34 | TERMINUSDB_QUICKSTART_JWKS=${TERMINUSDB_JWKS_ENDPOINT:-''} 35 | TERMINUSDB_QUICKSTART_INSECURE_USER_HEADER_ENABLED=${TERMINUSDB_INSECURE_USER_HEADER_ENABLED:-false} 36 | 37 | # HTTP 38 | TERMINUSDB_QUICKSTART_SCHEME="http" 39 | 40 | if [[ $TERMINUSDB_QUICKSTART_AUTOLOGIN == false ]]; then 41 | TERMINUSDB_QUICKSTART_SERVER_IP=${TERMINUSDB_SERVER_IP:-0.0.0.0} 42 | else 43 | TERMINUSDB_QUICKSTART_SERVER_IP="127.0.0.1" 44 | fi 45 | 46 | TERMINUSDB_URL="$TERMINUSDB_QUICKSTART_SCHEME://127.0.0.1:$TERMINUSDB_QUICKSTART_PORT/" 47 | 48 | if [[ "$(id -u)" == "0" || "$(uname)" == "Darwin" || "$TERM_PROGRAM" == "Apple_Terminal" ]]; then 49 | TERMINUSDB_QUICKSTART_DOCKER_DEFAULT="docker" 50 | elif command -v sudo >/dev/null; then 51 | TERMINUSDB_QUICKSTART_DOCKER_DEFAULT="sudo docker" 52 | else 53 | TERMINUSDB_QUICKSTART_DOCKER_DEFAULT="docker" 54 | fi 55 | 56 | TERMINUSDB_QUICKSTART_DOCKER=${TERMINUSDB_DOCKER:-$TERMINUSDB_QUICKSTART_DOCKER_DEFAULT} 57 | 58 | function remove_old_volumes { 59 | read -p "Are you sure? [y/N] " -r -n 1 60 | printf "\n" # (optional) move to a new line 61 | if [[ $REPLY =~ ^[Yy]$ ]]; then 62 | if ! $TERMINUSDB_QUICKSTART_DOCKER volume rm terminus_config $TERMINUSDB_QUICKSTART_STORAGE_VOLUME; then 63 | printf "Could not remove volumes. Are you running an existing container of TerminusDB? Stop it first.\n" 64 | fi 65 | else 66 | exit 2 67 | fi 68 | } 69 | 70 | function version_check { 71 | # The old TerminusDB had a prefix.db file needed, the new one 72 | # does not as prefixes are handled in a different way. Therefore 73 | # it is safe to assume that an existing storage volume with the 74 | # prefix.db is a user running an old version of TerminusDB 75 | if ! $TERMINUSDB_QUICKSTART_DOCKER volume inspect "$TERMINUSDB_QUICKSTART_STORAGE" > /dev/null 2>&1; then 76 | # no volume? then it will be created later on and further checks are unnecessary 77 | return 0 78 | fi 79 | 80 | if $TERMINUSDB_QUICKSTART_DOCKER run --rm -v "$TERMINUSDB_QUICKSTART_STORAGE_VOLUME":/home/ alpine cat /home/prefix.db > /dev/null 2>&1; then 81 | printf "\ 82 | You are running an old version of terminusdb-server. The new %s version 83 | uses a very different data structure which breaks backwards compatibility. 84 | Continuing will remove your existing databases.\n" "$TERMINUSDB_QUICKSTART_TAG" 85 | remove_old_volumes 86 | fi 87 | 88 | # Any other case will be handled by comparing storage version 89 | retrieve_storage_version 90 | STORAGE_VERSION=$? 91 | retrieve_expected_storage_version 92 | EXPECTED_STORAGE_VERSION=$? 93 | 94 | if [ $STORAGE_VERSION -gt $EXPECTED_STORAGE_VERSION ];then 95 | echo "Your TerminusDB store is not supported by this version of TerminusDB. Please upgrade TerminusDB." 96 | exit 1 97 | elif [ $STORAGE_VERSION -lt $EXPECTED_STORAGE_VERSION ];then 98 | echo "Your store is outdated and needs to be upgraded. Run \`terminusdb-container upgrade\` to do so." 99 | exit 1 100 | fi 101 | } 102 | 103 | if [[ -z "$TERMINUSDB_LABEL_FILE" ]]; then 104 | TERMINUSDB_QUICKSTART_SET_LABEL_FILE="" 105 | else 106 | TERMINUSDB_QUICKSTART_SET_LABEL_FILE="--label-file \"$TERMINUSDB_LABEL_FILE\"" 107 | fi 108 | 109 | if [[ -z "$TERMINUSDB_NETWORK" ]]; then 110 | TERMINUSDB_QUICKSTART_SET_NETWORK="" 111 | else 112 | TERMINUSDB_QUICKSTART_SET_NETWORK="--network \"$TERMINUSDB_NETWORK\"" 113 | fi 114 | 115 | if [[ -z "$TERMINUSDB_LOCAL" ]]; then 116 | TERMINUSDB_QUICKSTART_MOUNT_LOCAL="" 117 | else 118 | TERMINUSDB_QUICKSTART_MOUNT_LOCAL="-v \"$TERMINUSDB_LOCAL\":/app/local_files" 119 | fi 120 | 121 | if [[ -z "$TERMINUSDB_DASHBOARD_LOCAL_PATH" ]]; then 122 | TERMINUSDB_QUICKSTART_DASHBOARD_COMMAND="" 123 | else 124 | TERMINUSDB_QUICKSTART_DASHBOARD_COMMAND="-v \"$TERMINUSDB_DASHBOARD_LOCAL_PATH\":/app/terminusdb/dashboard" 125 | fi 126 | 127 | # 128 | # FUNCTIONS 129 | # 130 | 131 | _check_if_docker_is_in_path () { 132 | if ! $TERMINUSDB_QUICKSTART_DOCKER --version > /dev/null; then 133 | printf "Error! We searched for a way to run '%s', but, sadly, we couldn't find it.\n" \ 134 | "$TERMINUSDB_QUICKSTART_DOCKER" 135 | exit 1 136 | fi 137 | } 138 | 139 | # Run platform check 140 | _platform_check () { 141 | PLATFORM_ARCHITECTURE=$(uname -m) 142 | if [[ $PLATFORM_ARCHITECTURE != "x86_64" ]] && [[ $PLATFORM_ARCHITECTURE != "arm64" ]]; then 143 | printf "\ 144 | There are no Docker images for other CPU architectures than x86_64 and arm64 yet. 145 | You can try to manually compile the components of TerminusDB by following the 146 | instructions on the terminusdb-server repository although other architectures are not 147 | officially supported yet. 148 | https://github.com/terminusdb/terminusdb-server/blob/master/docs/BUILD.md \n" 149 | exit 4 150 | fi 151 | } 152 | 153 | _usage () { 154 | printf "\ 155 | USAGE: 156 | terminusdb-container [COMMAND] 157 | 158 | help show usage 159 | run run container 160 | cli use the terminusdb cli 161 | stop stop container 162 | attach attach to prolog shell 163 | exec execeute a command inside the container 164 | upgrade attempt to upgrade the storage to the latest version of terminusdb 165 | rm remove volumes\n" 166 | } 167 | 168 | _confirm() { 169 | read -r -p "Are you sure? [y/N] " RESPONSE 170 | case "$RESPONSE" in 171 | [yY][eE][sS]|[yY]) 172 | return 0 173 | ;; 174 | *) 175 | return 1 176 | ;; 177 | esac 178 | } 179 | 180 | retrieve_storage_version () { 181 | # shellcheck disable=SC2046 182 | return $(eval "$TERMINUSDB_QUICKSTART_DOCKER" run --rm \ 183 | "-v \"$TERMINUSDB_QUICKSTART_STORAGE:/storage:rw\"" \ 184 | "$TERMINUSDB_QUICKSTART_REPOSITORY:$TERMINUSDB_QUICKSTART_TAG" \ 185 | cat /storage/db/STORAGE_VERSION) 186 | } 187 | 188 | retrieve_terminusdb_major_version() { 189 | # shellcheck disable=SC2046 190 | return $(eval "$TERMINUSDB_QUICKSTART_DOCKER" run --rm \ 191 | "-v \"$TERMINUSDB_QUICKSTART_STORAGE:/storage:rw\"" \ 192 | "$TERMINUSDB_QUICKSTART_REPOSITORY:$TERMINUSDB_QUICKSTART_TAG" \ 193 | ./terminusdb --version|grep 'TerminusDB v'|perl -pe 's|TerminusDB v([0-9]+).*|\1|') 194 | } 195 | 196 | retrieve_expected_storage_version() { 197 | retrieve_terminusdb_major_version 198 | MAJOR_VERSION=$? 199 | case $MAJOR_VERSION in 200 | 10) 201 | return 1 202 | ;; 203 | 11) 204 | return 2 205 | ;; 206 | *) 207 | echo "TerminusDB version $MAJOR_VERSION is not supported by bootstrap" 208 | exit 1 209 | ;; 210 | esac 211 | } 212 | 213 | upgrade_image() { 214 | if [[ $TERMINUSDB_QUICKSTART_TAG == "latest" || $TERMINUSDB_QUICKSTART_TAG == "dev" ]]; then 215 | $TERMINUSDB_QUICKSTART_DOCKER image rm "$TERMINUSDB_QUICKSTART_REPOSITORY:$TERMINUSDB_QUICKSTART_TAG" 2>/dev/null 216 | fi 217 | } 218 | 219 | _run () { 220 | if [[ -z "$TERMINUSDB_QUICKSTART_JWKS" ]]; then 221 | TERMINUSDB_QUICKSTART_JWKS_ENV="" 222 | else 223 | TERMINUSDB_QUICKSTART_JWKS_ENV="-e TERMINUSDB_SERVER_JWKS_ENDPOINT=\"$TERMINUSDB_QUICKSTART_JWKS\"" 224 | fi 225 | eval "$TERMINUSDB_QUICKSTART_DOCKER" run -d -it --rm \ 226 | "--name \"$TERMINUSDB_QUICKSTART_CONTAINER\" -p \"$TERMINUSDB_QUICKSTART_SERVER_IP:$TERMINUSDB_QUICKSTART_PORT:6363\"" \ 227 | "-v \"$TERMINUSDB_QUICKSTART_STORAGE:$TERMINUSDB_QUICKSTART_STORAGE_VOLUME:rw\"" \ 228 | "$TERMINUSDB_QUICKSTART_DASHBOARD_COMMAND" \ 229 | "$TERMINUSDB_QUICKSTART_MOUNT_LOCAL" \ 230 | "$TERMINUSDB_QUICKSTART_SET_LABEL_FILE" \ 231 | "$TERMINUSDB_QUICKSTART_SET_NETWORK" \ 232 | "-e TERMINUSDB_SERVER_PORT=6363" \ 233 | "$TERMINUSDB_QUICKSTART_JWKS_ENV" \ 234 | "-e TERMINUSDB_INSECURE_USER_HEADER_ENABLED=\"$TERMINUSDB_QUICKSTART_INSECURE_USER_HEADER_ENABLED\"" \ 235 | "-e TERMINUSDB_LOG_FORMAT=\"$TERMINUSDB_LOG_FORMAT\"" \ 236 | "-e TERMINUSDB_LOG_LEVEL=\"$TERMINUSDB_LOG_LEVEL\"" \ 237 | "-e TERMINUSDB_INSECURE_USER_HEADER=\"$TERMINUSDB_INSECURE_USER_HEADER\"" \ 238 | "-e TERMINUSDB_ADMIN_PASS=\"$TERMINUSDB_QUICKSTART_PASS\"" \ 239 | "-e TERMINUSDB_AUTOLOGIN_ENABLED=\"$TERMINUSDB_QUICKSTART_AUTOLOGIN\"" \ 240 | "-e TERMINUSDB_JWT_ENABLED=\"$TERMINUSDB_QUICKSTART_JWT_ENABLED\"" \ 241 | "-e TERMINUSDB_JWT_AGENT_NAME_PROPERTY=\"$TERMINUSDB_QUICKSTART_JWT_AGENT_NAME_PROPERTY\"" \ 242 | "$TERMINUSDB_QUICKSTART_REPOSITORY:$TERMINUSDB_QUICKSTART_TAG" 243 | } 244 | 245 | _cli () { 246 | EXTRA_OPTIONS="" 247 | if echo "$TERMINUSDB_RUN_CMD" | grep -q '^\(fetch\|clone\|push\|pull\|user\)' 248 | then 249 | EXTRA_OPTIONS="-t" 250 | fi 251 | eval "$TERMINUSDB_QUICKSTART_DOCKER" -i "$EXTRA_OPTIONS" \ 252 | "$TERMINUSDB_QUICKSTART_CONTAINER" \ 253 | "./terminusdb" \ 254 | "$TERMINUSDB_RUN_CMD" 255 | } 256 | 257 | _stop () { 258 | $TERMINUSDB_QUICKSTART_DOCKER stop "$TERMINUSDB_QUICKSTART_CONTAINER" 259 | } 260 | 261 | _restart () { 262 | $TERMINUSDB_QUICKSTART_DOCKER stop "$TERMINUSDB_QUICKSTART_CONTAINER" 263 | } 264 | 265 | _attach () { 266 | $TERMINUSDB_QUICKSTART_DOCKER attach "$TERMINUSDB_QUICKSTART_CONTAINER" 267 | } 268 | 269 | _exec () { 270 | if [[ -n "$TERMINUSDB_RUN_CMD" ]]; then 271 | eval "$TERMINUSDB_QUICKSTART_DOCKER" exec -it \ 272 | "$TERMINUSDB_QUICKSTART_CONTAINER" \ 273 | "$TERMINUSDB_RUN_CMD" 274 | fi 275 | } 276 | 277 | _rm () { 278 | if _confirm; then 279 | $TERMINUSDB_QUICKSTART_DOCKER volume rm "$TERMINUSDB_QUICKSTART_STORAGE" 280 | fi 281 | } 282 | 283 | _serve () { 284 | if command -v python >/dev/null; then 285 | python -m http.server 8888 286 | else 287 | printf "\npython is required for this feature\n" 288 | fi 289 | } 290 | 291 | _upgrade() { 292 | $TERMINUSDB_QUICKSTART_DOCKER run \ 293 | -e TERMINUSDB_QUICKSTART_STORAGE="$TERMINUSDB_QUICKSTART_STORAGE_VOLUME" \ 294 | -v "$TERMINUSDB_QUICKSTART_STORAGE:$TERMINUSDB_QUICKSTART_STORAGE_VOLUME:rw" \ 295 | --rm terminusdb/terminusdb-upgrade 296 | } 297 | 298 | printf "\nTERMINUSDB-BOOTSTRAP IS DEPRECATED. Use the docker compose in the main TerminusDB repository instead or check our " 299 | printf "documentation regarding server and Kubernetes deployments\n\n" 300 | 301 | _platform_check 302 | # 303 | # PROCESS ARGS 304 | # 305 | 306 | if [[ -n "$1" ]]; then 307 | case "$1" in 308 | "help") 309 | _usage 310 | ;; 311 | "run") 312 | # _build 313 | _check_if_docker_is_in_path 314 | upgrade_image 315 | version_check 316 | _run > /dev/null \ 317 | && printf "terminusdb-server container started %s\n" "$TERMINUSDB_URL" \ 318 | || printf "\nIs the container already running?\n" 319 | ;; 320 | "cli") 321 | _check_if_docker_is_in_path 322 | if [[ -n "$2" ]]; then 323 | # shellcheck disable=SC2124 324 | TERMINUSDB_RUN_CMD="${@:2}" 325 | fi 326 | _cli || printf "\nError on executing the CLI command, did you forget to run the container first with the run command?" 327 | ;; 328 | "stop") 329 | _check_if_docker_is_in_path 330 | _stop > /dev/null \ 331 | && printf "terminusdb-server container stopped\n" \ 332 | || printf "\nIs the container running?\n" 333 | ;; 334 | "attach") 335 | _check_if_docker_is_in_path 336 | printf "Ctrl+p Ctrl+q to detach\n\n" 337 | _attach 338 | ;; 339 | "rm") 340 | _check_if_docker_is_in_path 341 | printf "This will delete storage volume\n" 342 | _rm \ 343 | || printf "\nIs the container stopped?\n" 344 | ;; 345 | "exec") 346 | _check_if_docker_is_in_path 347 | if [[ -n "$2" ]]; then 348 | # shellcheck disable=SC2124 349 | TERMINUSDB_RUN_CMD="${@:2}" 350 | fi 351 | printf "This will exec a command on terminusdb-server\n" 352 | _exec \ 353 | || printf "\nIs the container stopped?\n" 354 | ;; 355 | "upgrade") 356 | _upgrade 357 | ;; 358 | "nop") 359 | true 360 | ;; 361 | "serve") 362 | _check_if_docker_is_in_path 363 | _serve 364 | ;; 365 | *) 366 | printf "Error! Command unknown: %s\n\n" "$1" 367 | _usage 368 | exit 1 369 | ;; 370 | esac 371 | else 372 | _usage 373 | fi 374 | 375 | # vim:ft=sh 376 | --------------------------------------------------------------------------------