-
Notifications
You must be signed in to change notification settings - Fork 2
Optimize: size #6
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
094b6c3
optimize: size.
ItzNotABug e1880c6
optimize: size, a bit more.
ItzNotABug e9da520
Merge branch 'main' into 'smaller-size'.
ItzNotABug 1be05ed
bump: pnpm.
ItzNotABug 4fea438
fix: version.
ItzNotABug 42c1fbb
address comments.
ItzNotABug fb7c215
remove: modclean.
ItzNotABug 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 |
|---|---|---|
| @@ -1,19 +1,43 @@ | ||
| FROM node:22-slim AS base | ||
| ENV PNPM_HOME="/pnpm" | ||
| ENV PATH="$PNPM_HOME:$PATH" | ||
| RUN corepack enable | ||
| # install and optimize dependencies | ||
| FROM zenika/alpine-chrome:with-node AS base | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # copy package files | ||
| COPY package.json pnpm-lock.yaml ./ | ||
| RUN corepack prepare | ||
|
|
||
| FROM base AS prod-deps | ||
| RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile | ||
| # install pnpm as root, | ||
| # then switch back to chrome user | ||
| USER root | ||
| RUN npm install -g pnpm@10 | ||
ItzNotABug marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # install dependencies as normal user | ||
| USER chrome | ||
| RUN pnpm install --prod --frozen-lockfile && \ | ||
| pnpm prune --prod && \ | ||
| # remove unnecessary files to reduce image size | ||
| find /app/node_modules -name "*.md" -delete && \ | ||
| find /app/node_modules -type d -name "test*" -exec rm -rf {} + 2>/dev/null || true && \ | ||
| find /app/node_modules -type d -name "doc*" -exec rm -rf {} + 2>/dev/null || true && \ | ||
| find /app/node_modules -name ".cache" -type d -exec rm -rf {} + 2>/dev/null || true && \ | ||
| # clean up caches | ||
| rm -rf ~/.pnpm ~/.npm /tmp/* /var/cache/apk/* | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
ItzNotABug marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # production stage | ||
| FROM zenika/alpine-chrome:with-node | ||
ItzNotABug marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # environment configuration | ||
| ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 \ | ||
| PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium-browser \ | ||
| NODE_ENV=production | ||
|
|
||
| WORKDIR /app | ||
| USER chrome | ||
|
|
||
| FROM base AS build | ||
| COPY . . | ||
| # copy application files | ||
| COPY package.json ./ | ||
| COPY --from=base /app/node_modules ./node_modules | ||
| COPY src/index.js ./src/ | ||
ItzNotABug marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| FROM base | ||
| COPY --from=prod-deps /app/node_modules /app/node_modules | ||
| RUN pnpm playwright install --with-deps chromium | ||
| COPY --from=build /app/src/index.js /app/src/index.js | ||
| CMD ["pnpm", "start"] | ||
| # start the application | ||
| CMD ["node", "src/index.js"] | ||
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,10 @@ | ||
| services: | ||
| appwrite-browser: | ||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile | ||
| image: appwrite/browser:local | ||
| ports: | ||
| - "3000:3000" | ||
| environment: | ||
| - PORT=3000 |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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.
Uh oh!
There was an error while loading. Please reload this page.