Skip to content

Conversation

@Saru2003
Copy link

Description

This PR optimizes the Docker build process for the AsyncAPI CLI. The current Docker image is large and takes a long time to build. These changes address both of those concerns:

Changes Made:

  • Rewrote the Dockerfile using a multi-stage build to separate dependencies and runtime.
  • Switched to ghcr.io/puppeteer/puppeteer:20.8.0 as the base image - it includes Chromium out of the box, which is required by some templates.
  • Added a .dockerignore file to exclude unnecessary files like node_modules, .git, test, etc., reducing build context.
  • Removed unused dev tools and temporary folders post-build to slim down the image.
  • Used npm prune --omit=dev to eliminate devDependencies from the final image.
  • Switched to a non-root user (myuser) for safer container execution.
  • Created a symlink /usr/local/bin/asyncapi so the CLI can be invoked directly.

Performance Comparison

Image Tag Size (GB) Build Time (s) Size Reduction Build Time Improvement
asyncapi-cli-unoptimized 5.53 GB 530 s
asyncapi-cli-revised 4.32 GB 245 s ↓ 1.21 GB (↓21.88%) ↓ 285 s (↓53.77%)

Build and runtime tested locally using a fork of the repository.


How to Build & Run

docker build -t asyncapi-cli.

docker run -it --entrypoint sh asyncapi-cli

asyncapi --version

Related issue(s)
Resolves #1798

@changeset-bot
Copy link

changeset-bot bot commented Jul 10, 2025

🦋 Changeset detected

Latest commit: 2e155c8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@asyncapi/cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@github-actions
Copy link
Contributor

Changeset has been generated for this PR as part of auto-changeset workflow.

Please review the changeset before merging the PR.
---
'@asyncapi/cli': minor
---

feat: optimize Dockerfile to reduce image size and build time

- 4b0017d: build: optimize Dockerfile and add .dockerignore to reduce image size

If you are a maintainer or the author of the PR, you can change the changeset by clicking here

Tip

If you don't want auto-changeset to run on this PR, you can add the label skip-changeset to the PR or remove the changeset and change PR title to something other than fix: or feat:.

@sonarqubecloud
Copy link

@aeworxet
Copy link
Contributor

The GitHub issue #1798 participates in the strictly serial AsyncAPI Bounty Program and is the responsibility of the assigned user.

You are welcome to choose another GitHub issue for contribution.

@sonarqubecloud
Copy link

@github-actions
Copy link
Contributor

This pull request has been automatically marked as stale because it has not had recent activity 😴

It will be closed in 120 days if no further activity occurs. To unstale this pull request, add a comment with detailed explanation.

There can be many reasons why some specific pull request has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this pull request forward. Connect with us through one of many communication channels we established here.

Thank you for your patience ❤️

@github-actions github-actions bot added the stale label Dec 13, 2025
@Shurtu-gal
Copy link
Collaborator

@Saru2003 as the issue has now been removed from bounty program could you please continue your work on this?

@github-actions github-actions bot removed the stale label Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Triage

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Docker images are take too long to build and are quite large.

3 participants