diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..a62800109 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,2 @@ +FROM node:18.19.0-alpine3.18 AS base +RUN wget -qO- https://get.pnpm.io/install.sh | ENV="$HOME/.shrc" SHELL="$(which sh)" sh - diff --git a/docker-compose.yml b/docker-compose.yml index 733f5d9a7..1c6f4458a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,11 +1,14 @@ version: '3.9' services: mermaid: - image: node:18.19.0-alpine3.18 + build: + context: . + dockerfile: Dockerfile stdin_open: true tty: true working_dir: /mermaid mem_limit: '8G' + entrypoint: "/mermaid/docker-entrypoint.sh" environment: - NODE_OPTIONS=--max_old_space_size=8192 volumes: diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 000000000..c222b7fd5 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,3 @@ +#!/bin/sh +source /root/.shrc +exec "$@" diff --git a/packages/mermaid/src/docs/community/contributing.md b/packages/mermaid/src/docs/community/contributing.md index c8f49dbaa..9a83b5294 100644 --- a/packages/mermaid/src/docs/community/contributing.md +++ b/packages/mermaid/src/docs/community/contributing.md @@ -45,17 +45,18 @@ We support **development within Docker** environment along with **host setup**. These are the tools we use for working with the code and documentation: -- [volta](https://volta.sh/) to manage node versions. -- [Node.js](https://nodejs.org/en/). `volta install node` -- [pnpm](https://pnpm.io/) package manager. `volta install pnpm` +- [Node.js](https://nodejs.org/en/). +- [pnpm](https://pnpm.io/) package manager. -In case you do not use `volta` the following commands must be sufficient enough to start with: +The following commands must be sufficient enough to start with: ```bash curl -fsSL https://get.pnpm.io/install.sh | sh - pnpm env use --global 18 ``` +You may also need to reload `.shrc` or `.bashrc` afterwards. + **Docker** [Install Docker](https://docs.docker.com/engine/install/). And that is pretty much all you need. diff --git a/run b/run index 920e346f8..ea23d28de 100755 --- a/run +++ b/run @@ -1,5 +1,5 @@ #!/bin/bash -RUN="docker-compose run --rm" +RUN="docker compose run --rm" ansi() { echo -e "\e[${1}m${*:2}\e[0m"; } bold() { ansi 1 "$@"; } @@ -14,16 +14,20 @@ args=${@:2} case $command in +build) +docker compose build $args +;; + sh) -$RUN mermaid sh -c "npx $args" +$RUN mermaid sh # -c "npx $args" ;; pnpm) -$RUN mermaid sh -c "npx pnpm $args" +$RUN mermaid sh -c "pnpm $args" ;; dev) -$RUN --service-ports mermaid sh -c "npx pnpm run dev" +$RUN --service-ports mermaid sh -c "pnpm run dev" ;; docs:dev) @@ -46,24 +50,26 @@ Welcome! Thank you for joining the development. This is a script for running commands within docker containers at ease. __________________________________________________________________________________________ -Development quick start guide: +Development Quick Start Guide: -$(bold ./$name pnpm install) # Install packages -$(bold ./$name dev) # Run dev server with examples, open http://localhost:9000 -$(bold ./$name pnpm vitest) # Run watcher for unit tests -$(bold ./$name cypress) # Run integration tests (after starting dev server) -$(bold ./$name pnpm build) # Prepare it for production -$(bold ./$name docs:dev) # Then add documentation, open http://localhost:3333 +$(bold ./$name pnpm install) # Install packages +$(bold ./$name dev) # Launch dev server with examples, open http://localhost:9000 +$(bold ./$name docs:dev) # Launch official website, open http://localhost:3333 + +$(bold ./$name pnpm vitest) # Run watcher for unit tests +$(bold ./$name cypress) # Run integration tests (after starting dev server) +$(bold ./$name pnpm build) # Prepare it for production __________________________________________________________________________________________ Commands: -$(bold ./$name pnpm) # Run any 'pnpm' command -$(bold ./$name dev) # Run dev server with examples, open http://localhost:9000 -$(bold ./$name docs:dev) # For docs contributions, open http://localhost:3333 -$(bold ./$name cypress) # Run integration tests -$(bold ./$name sh) # Open 'sh' inside docker container for development -$(bold ./$name help) # Show this help +$(bold ./$name build) # Build image +$(bold ./$name cypress) # Run integration tests +$(bold ./$name dev) # Run dev server with examples, open http://localhost:9000 +$(bold ./$name docs:dev) # For docs contributions, open http://localhost:3333 +$(bold ./$name help) # Show this help +$(bold ./$name pnpm) # Run any 'pnpm' command +$(bold ./$name sh) # Open 'sh' inside docker container for development __________________________________________________________________________________________ Examples of frequiently used commands: @@ -81,7 +87,7 @@ $(bold ./$name cypress open --project .) Open cypress interactive GUI $(bold ./$name cypress run --spec cypress/integration/rendering/)$(underline test.spec.ts) - Run specific test in cypress\n + Run specific test in cypress $(bold xhost +local:) Allow local connections for x11 server