Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/slim-docker-and-on-demand-studio.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@asyncapi/cli": minor
---

feat: reduce install/image size by making AsyncAPI Studio an on-demand dependency

`@asyncapi/studio` (and its transitive `next`) is no longer a runtime dependency — it is now a `devDependency`, so end-user (`npm install -g`) and Docker (`--omit=dev`) installs are ~450MB smaller, while its version stays tracked and locked for development. The first time you run `start studio`, `start preview`, or `new --studio` without Studio present, the CLI installs it on-demand into its data directory (the version is read from the CLI's declared `@asyncapi/studio` range). Pass `--yes`/`-y` (or set `ASYNCAPI_STUDIO_AUTO_INSTALL=1`) to install it without a prompt in non-interactive environments. The dead `generator-v2` dependency was also removed and the Docker image was slimmed further (removed the unused build toolchain, kept chromium for PDF generation).
29 changes: 29 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# Dependencies (reinstalled inside the image)
node_modules
npm-debug.log

# Docker
Dockerfile
.dockerignore

# VCS
.git
.gitignore
.gitattributes

# Tests, coverage and build output (not needed in the image)
test
coverage
output
.nyc_output

# Docs and project meta
docs
.github
.changeset
*.md

# Regenerated at build time
assets/examples

# Editor / tooling config
.vscode
.idea
.editorconfig
.prettierrc
eslint.config.mjs
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ feat: add new feature
## Additional commands

- Lint the code: `npm run lint`
- Build Docker image: `npm run docker:build`
- Build Docker image: `npm run docker:build` (the image excludes AsyncAPI Studio to stay small; `start studio`/`preview` install it on-demand)

## Troubleshooting

Expand Down
33 changes: 21 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,31 @@ RUN addgroup -S myuser && adduser -S myuser -G myuser

WORKDIR /app

# Since 0.14.0 release of html-template chromium is needed for pdf generation
ENV PUPPETEER_EXECUTABLE_PATH /usr/bin/chromium-browser
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
# Since 0.30.0 release Git is supported and required as a dependency
# Since 0.14.0 release of html-template chromium is needed for pdf generation.
# More custom packages for specific template should not be added to this dockerfile. Instead, we should come up with some extensibility solution.
RUN apk --update add git chromium && \
apk add --no-cache --virtual .gyp python3 make g++ && \
rm -rf /var/lib/apt/lists/* && \
rm /var/cache/apk/*
# Since 0.14.0 release of html-template, chromium is needed for PDF generation.
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
# Since 0.30.0 release Git is supported and required as a dependency.
# NOTE: @asyncapi/studio is no longer a hard dependency of the CLI, so it is not
# present in this image (keeps it ~450MB smaller). `asyncapi start studio`,
# `start preview` and `new --studio` will offer to install Studio on-demand into
# the container's data directory (pass `--yes` or ASYNCAPI_STUDIO_AUTO_INSTALL=1
# in non-interactive contexts). Chromium is kept so that html-template PDF
# generation works out of the box.
# More custom packages for specific templates should not be added to this
# dockerfile. Instead, we should come up with some extensibility solution.
RUN apk --update add --no-cache git chromium && \
rm -rf /var/cache/apk/*

# Copy the libraries directory from the build stage
COPY --from=build /libraries /libraries

# Install the dependencies
RUN cd /libraries && npm install --omit=dev --ignore-scripts
# Install production dependencies, then deduplicate and clean the npm cache to
# reduce the final image size. @asyncapi/studio/next are not installed here
# because they are no longer runtime dependencies (installed on-demand instead).
RUN cd /libraries && \
npm install --omit=dev --ignore-scripts && \
npm dedupe && \
npm cache clean --force

# Create a script that runs the desired command
RUN ln -s /libraries/bin/run_bin /usr/local/bin/asyncapi
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ src/
- **Core:** `validate`, `convert`, `format`, `optimize`, `diff`, `bundle`
- **Generation:** `generate client`, `generate models`, `generate fromTemplate`
- **Config:** `config context`, `config analytics`, `config versions`
- **Utility:** `new file`, `new template`, `start api|studio|preview`, `pretty`
- **Utility:** `new file`, `new template`, `start api|studio|preview`, `pretty` (Studio for `start studio`/`preview` is installed on-demand, not bundled)

### API Server

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The AsyncAPI CLI offers the following key features:

* Optimize: Using [Optimizer](https://github.com/asyncapi/optimizer/), the AsyncAPI CLI can be used to optimize an AsyncAPI specification file which can optimize the structure of the AsyncAPI document to make it smaller and without repetition.

* Start: The AsyncAPI CLI can be used to start [AsyncAPI Studio](https://studio.asyncapi.com/) locally, which the user can use to view, edit, and test AsyncAPI documents.
* Start: The AsyncAPI CLI can be used to start [AsyncAPI Studio](https://studio.asyncapi.com/) locally, which the user can use to view, edit, and test AsyncAPI documents. Studio is not bundled with the CLI; the first time you use it, the CLI installs it on-demand (~450MB).

To summarize, the AsyncAPI CLI offers the following features and process flow, as shown in the diagram below:

Expand Down
6 changes: 6 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ After installing Node.js and NPM, run the following command to install the Async
```sh
npm install -g @asyncapi/cli
```

> [!NOTE]
> AsyncAPI Studio is not bundled with the CLI to keep the install small. The first time you run `asyncapi start studio`, `asyncapi start preview`, or `asyncapi new --studio`, the CLI will ask to download Studio (~450MB) into its data directory. In non-interactive environments (like CI), pass `--yes` (or set `ASYNCAPI_STUDIO_AUTO_INSTALL=1`) to install it automatically.
To enable the autocomplete feature in the CLI for the shells **bash and zshrc**, there is a script that will run automatically and autocomplete is only support for **bash and zshrc** for the **powershell** refer to manually enabling [autocomplete](https://www.asyncapi.com/docs/tools/cli/autocompleteEnabled) guide in ClI:

After the ClI installation :
Expand Down Expand Up @@ -69,6 +72,9 @@ docker run --rm -it \
```
Note: Use ``` ` ``` instead of `\` for Windows.

> [!NOTE]
> The Docker image keeps chromium (so PDF generation with `@asyncapi/html-template` works out of the box) but does not bundle AsyncAPI Studio. Running `asyncapi start studio`/`start preview` inside the container will offer to install Studio on-demand; pass `--yes` (or set `ASYNCAPI_STUDIO_AUTO_INSTALL=1`) to install it without a prompt. Note that Studio starts a local web server, so you also need to publish the port (e.g. `-p 3210:3210`) to reach it from your host.


## Mac
There are two ways to install the AsyncAPI CLI on your macOS: using the `brew` package manager or `pkg` files.
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export default [
},
},
{
files: ['src/domains/models/Preview.ts', 'src/domains/models/Studio.ts', 'test/jest.setup.ts'],
files: ['src/domains/models/Preview.ts', 'src/domains/models/Studio.ts', 'src/domains/models/studio-runtime.ts', 'test/jest.setup.ts'],
rules: {
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-var-requires': 'off',
Expand Down
Loading
Loading