-
-
Notifications
You must be signed in to change notification settings - Fork 262
feat: asyncapi on alpine distros #1844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Gmin2
wants to merge
5
commits into
asyncapi:master
Choose a base branch
from
Gmin2:optimized-dcoker
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
de8e46a
feat: asyncapi on alpine distros
Gmin2 18f34d2
refactor: added dockerignore and improved Dockerfile
Gmin2 d0141a8
fix: update dockerfile and lock file and not include lock file in pre…
Gmin2 dc87fff
fix: update dockerfile and dockerignore to new github-action dockerfile
Gmin2 a9351cb
chore: add changeset for PR #1844
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| '@asyncapi/cli': minor | ||
| --- | ||
|
|
||
| feat: asyncapi on alpine distros | ||
|
|
||
| - de8e46a: feat: asyncapi on alpine distros | ||
| - 18f34d2: refactor: added dockerignore and improved Dockerfile | ||
| - d0141a8: fix: update dockerfile and lock file and not include lock file in pre commit hooks | ||
| - dc87fff: fix: update dockerfile and dockerignore to new github-action dockerfile | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,89 @@ | ||
|
|
||
| # Dependencies | ||
| node_modules | ||
| npm-debug.log | ||
| Dockerfile | ||
| .dockerignore | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| pnpm-debug.log* | ||
|
|
||
| # Build output | ||
| lib | ||
| dist | ||
| *.tgz | ||
| *.tar.gz | ||
|
|
||
| # Testing | ||
| test | ||
| coverage | ||
| .nyc_output | ||
| *.test.* | ||
| *.spec.* | ||
| __tests__ | ||
| __mocks__ | ||
|
|
||
| # Development | ||
| .git | ||
| .gitignore | ||
| .github | ||
| .vscode | ||
| .idea | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
|
|
||
| # Documentation | ||
| docs | ||
| *.md | ||
| !README.md | ||
| CHANGELOG.md | ||
| CONTRIBUTING.md | ||
| CODE_OF_CONDUCT.md | ||
| DEVELOPMENT.md | ||
|
|
||
| # Temporary files and directories | ||
| tmp | ||
| temp | ||
| .tmp | ||
| .temp | ||
| .cache | ||
|
|
||
| # Environment and config files | ||
| .env* | ||
| .eslintrc* | ||
| .prettierrc* | ||
| lefthook.yml | ||
| nodemon.json | ||
| jest.config.* | ||
| commitlint.config.js | ||
|
|
||
| # OS specific files | ||
| .DS_Store | ||
| Thumbs.db | ||
|
|
||
| # IDE files | ||
| *.sublime-project | ||
| *.sublime-workspace | ||
|
|
||
| # Logs | ||
| logs | ||
| *.log | ||
|
|
||
| # Optional npm cache directory | ||
| .npm | ||
|
|
||
| # Optional eslint cache | ||
| .eslintcache | ||
|
|
||
| # TypeScript cache | ||
| *.tsbuildinfo | ||
|
|
||
| # Notes and misc | ||
| notes.md | ||
| pnpm-lock.yaml | ||
|
|
||
| # Action files (for main CLI docker image) | ||
| action.yml | ||
| action-template.yml | ||
|
|
||
| # Test directories and files | ||
| test-alpine-fix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,70 +1,49 @@ | ||
| # Stage 1: Build | ||
| FROM node:20-alpine AS build | ||
| WORKDIR /app | ||
|
|
||
| # Copy the source code | ||
| COPY ./ /tmp/source_code | ||
|
|
||
| # Install dependencies | ||
| RUN cd /tmp/source_code && npm install --ignore-scripts | ||
|
|
||
| # Build the source code | ||
| RUN cd /tmp/source_code && npm run build | ||
|
|
||
| # create libraries directory | ||
| RUN mkdir -p /libraries | ||
| # Copy package files first for better caching | ||
| COPY package*.json ./ | ||
|
|
||
| # Copy the lib, bin, node_modules, and package.json files to the /libraries directory | ||
| RUN cp -r /tmp/source_code/lib /libraries | ||
| RUN cp -r /tmp/source_code/assets /libraries | ||
| RUN cp /tmp/source_code/package.json /libraries | ||
| RUN cp /tmp/source_code/package-lock.json /libraries | ||
| RUN cp /tmp/source_code/oclif.manifest.json /libraries | ||
| # Install all dependencies (including dev dependencies for build) | ||
| RUN npm ci --ignore-scripts | ||
|
|
||
| # Copy the bin directory to the /libraries directory | ||
| RUN cp -r /tmp/source_code/bin /libraries | ||
| # Copy only necessary files for build | ||
| COPY src/ ./src/ | ||
| COPY assets/ ./assets/ | ||
| COPY scripts/ ./scripts/ | ||
| COPY bin/ ./bin/ | ||
| COPY tsconfig.json ./ | ||
| RUN npm run build && \ | ||
| npm prune --omit=dev && \ | ||
| rm -rf test docs .git tmp node_modules/.cache | ||
|
|
||
| # Remove everything inside /tmp | ||
| RUN rm -rf /tmp/* | ||
| # Stage 2: Runtime | ||
| FROM ghcr.io/puppeteer/puppeteer:20.8.0 | ||
|
|
||
| FROM node:20-alpine | ||
| # Switch to root to create user and set up permissions | ||
| USER root | ||
|
|
||
| # Set ARG to explicit value to build chosen version. Default is "latest" | ||
| ARG ASYNCAPI_CLI_VERSION= | ||
| # Install git | ||
| RUN rm -f /etc/apt/sources.list.d/google*.list && \ | ||
| apt-get update && \ | ||
| apt-get install -y git && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Create a non-root user | ||
| RUN addgroup -S myuser && adduser -S myuser -G myuser | ||
| # Create non-root user | ||
| RUN groupadd -r asyncapi && useradd -r -g asyncapi asyncapi | ||
|
|
||
| # Copy built files from builder stage with correct ownership | ||
| WORKDIR /app | ||
| COPY --from=build --chown=asyncapi:asyncapi /app /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/* | ||
|
|
||
| # Copy the libraries directory from the build stage | ||
| COPY --from=build /libraries /libraries | ||
|
|
||
| # Install the dependencies | ||
| RUN cd /libraries && npm install --production --ignore-scripts | ||
|
|
||
| # Create a script that runs the desired command | ||
| RUN ln -s /libraries/bin/run_bin /usr/local/bin/asyncapi | ||
|
|
||
| # Make the script executable | ||
| RUN chmod +x /usr/local/bin/asyncapi | ||
|
|
||
| # Change ownership to non-root user | ||
| RUN chown -R myuser:myuser /libraries /usr/local/bin/asyncapi || echo "Failed to change ownership" | ||
| # Create symlink and set permissions | ||
| RUN ln -s /app/bin/run_bin /usr/local/bin/asyncapi && \ | ||
| chmod +x /usr/local/bin/asyncapi | ||
|
|
||
| RUN chown -R myuser:myuser /usr/local/lib/node_modules && \ | ||
| chown -R myuser:myuser /usr/local/bin | ||
| # Switch to non-root user for runtime | ||
| USER asyncapi | ||
|
|
||
| # Switch to the non-root user | ||
| USER myuser | ||
| ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true | ||
|
|
||
| ENTRYPOINT [ "asyncapi" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,8 +3,10 @@ pre-commit: | |
| commands: | ||
| lint: | ||
| run: npm run lint | ||
| exclude: 'package-lock.json' | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this needed? |
||
| test: | ||
| run: npm run test | ||
| exclude: 'package-lock.json' | ||
|
|
||
| commit-msg: | ||
| parallel: true | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't we need to install node_modules again?