Merge pull request #4478 from nirname/feature/docker-development-support

Support for development in Docker
This commit is contained in:
Sidharth Vinod 2023-06-15 10:34:09 +05:30 committed by GitHub
commit 8426716886
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 65 additions and 0 deletions

2
.gitignore vendored
View File

@ -3,8 +3,10 @@
node_modules/
coverage/
.idea/
.pnpm-store/
dist
v8-compile-cache-0
yarn-error.log
.npmrc

View File

@ -18,14 +18,28 @@ https://docs.github.com/en/get-started/quickstart/fork-a-repo
## Development Installation
If you don't have direct access to push to mermaid repositories, make a fork first. Then clone. Or clone directly from mermaid-js:
```bash
git clone git@github.com:mermaid-js/mermaid.git
cd mermaid
```
Install required packages:
```bash
# npx is required for first install as volta support for pnpm is not added yet.
npx pnpm install
pnpm test
```
If you are using docker and docker-compose, you have self-documented `run` bash script, which is a convenient alias for docker-compose commands:
```bash
./run install # npx pnpm install
./run test # pnpm test
```
## Committing code
We make all changes via pull requests. As we have many pull requests from developers new to mermaid, the current approach is to have _knsv, Knut Sveidqvist_ as a main reviewer of changes and merging pull requests. More precisely like this:

9
docker-compose.yml Normal file
View File

@ -0,0 +1,9 @@
version: '3.9'
services:
mermaid:
image: node:18.16.0-alpine3.18
stdin_open: true
tty: true
working_dir: /mermaid
volumes:
- ./:/mermaid

40
run Executable file
View File

@ -0,0 +1,40 @@
#!/bin/bash
RUN="docker-compose run --rm"
command=$1
args=${@:2}
case $command in
sh)
$RUN mermaid sh $args
;;
install)
$RUN mermaid sh -c "npx pnpm install"
;;
test)
$RUN mermaid sh -c "npx pnpm test"
;;
lint)
$RUN mermaid sh -c "npx pnpm -w run lint:fix"
;;
help)
cat <<EOF
Run commonly used commands within docker containers
$0 install # Equvalent of pnpm install
$0 lint # Equvalent of pnpm -w run lint:fix
$0 sh # Open sh inside docker container for development
$0 help # Show this help
EOF
;;
*)
$0 help
;;
esac