-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Optimize docker image for production #965
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,105 @@ | ||
| # We want the docker builds to be clean, and as fast as possible. Don't send | ||
| # any half-built stuff in the build context as a pre-caution (also saves copying | ||
| # 180k files in node_modules that isn't used!). | ||
| # Dependencies | ||
| **/node_modules | ||
| node_modules/* | ||
| node_modules | ||
| docker-data/* | ||
| dist | ||
| .nx | ||
| /apps/frontend/.next | ||
| /apps/backend/dist | ||
| /apps/workers/dist | ||
| /apps/cron/dist | ||
| /apps/commands/dist | ||
| .devcontainer | ||
| **/.git | ||
| **/*.md | ||
| **/LICENSE | ||
| **/npm-debug.log | ||
| **/*.vscode | ||
| pnpm-debug.log* | ||
|
|
||
| # Production builds | ||
| **/dist | ||
| **/.next | ||
| **/build | ||
| **/out | ||
|
|
||
| # Environment files | ||
| .env | ||
| .env.local | ||
| .env.development.local | ||
| .env.test.local | ||
| .env.production.local | ||
|
|
||
| # IDE and editor files | ||
| .vscode | ||
| .idea | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
|
|
||
| # OS generated files | ||
| .DS_Store | ||
| .DS_Store? | ||
| ._* | ||
| .Spotlight-V100 | ||
| .Trashes | ||
| ehthumbs.db | ||
| Thumbs.db | ||
|
|
||
| # Git | ||
| .git | ||
| .github | ||
| reports | ||
| .gitignore | ||
|
|
||
| # Docker | ||
| Dockerfile* | ||
| docker-compose* | ||
| .dockerignore | ||
|
|
||
| # Logs | ||
| logs | ||
| *.log | ||
|
|
||
| # Runtime data | ||
| pids | ||
| *.pid | ||
| *.seed | ||
| *.pid.lock | ||
|
|
||
| # nyc test coverage | ||
| .nyc_output | ||
|
|
||
| # Optional npm cache directory | ||
| **/.npm | ||
|
|
||
| # Optional eslint cache | ||
| .eslintcache | ||
|
|
||
| # Next.js build output | ||
| **/.next | ||
|
|
||
| **/.cache/ | ||
|
|
||
| # Storybook build outputs | ||
| **/.out | ||
| **/.storybook-out | ||
|
|
||
| # Temporary folders | ||
| tmp/ | ||
| temp/ | ||
|
|
||
| # Test files | ||
| test | ||
| tests | ||
| __tests__ | ||
| *.test.js | ||
| *.test.ts | ||
| *.test.tsx | ||
| *.spec.js | ||
| *.spec.ts | ||
| *.spec.tsx | ||
|
|
||
| # Documentation | ||
| README.md | ||
| CHANGELOG.md | ||
| CONTRIBUTING.md | ||
|
|
||
|
|
||
| # Reports | ||
| coverage/ | ||
|
|
||
| # Uploads and var directories | ||
| uploads/ | ||
| var/docker/docker-build.sh | ||
| var/docker/docker-create.sh | ||
|
|
||
| # Jest | ||
| jest.config.js | ||
| jest.setup.js |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,76 @@ | ||||||||||
| # ---- Dependencies stage ---- | ||||||||||
| FROM node:20-alpine3.19 AS deps | ||||||||||
|
|
||||||||||
| RUN apk add --no-cache g++ make py3-pip bash | ||||||||||
| RUN npm --no-update-notifier --no-fund --global install [email protected] | ||||||||||
|
|
||||||||||
| WORKDIR /app | ||||||||||
|
|
||||||||||
| COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ | ||||||||||
| COPY apps/*/package.json ./apps/ | ||||||||||
| COPY libraries/*/package.json ./libraries/ | ||||||||||
|
|
||||||||||
| RUN --mount=type=cache,id=pnpm-store,target=/root/.pnpm-store \ | ||||||||||
| pnpm install --ignore-scripts | ||||||||||
|
|
||||||||||
| # ---- Build stage ---- | ||||||||||
| FROM deps AS build | ||||||||||
|
|
||||||||||
| COPY . . | ||||||||||
|
|
||||||||||
| RUN --mount=type=cache,id=pnpm-store,target=/root/.pnpm-store \ | ||||||||||
| pnpm install | ||||||||||
|
|
||||||||||
| RUN NODE_OPTIONS="--max-old-space-size=4096" pnpm run build:backend | ||||||||||
| RUN NODE_OPTIONS="--max-old-space-size=4096" pnpm run build:workers | ||||||||||
| RUN NODE_OPTIONS="--max-old-space-size=4096" pnpm run build:cron | ||||||||||
| RUN NODE_OPTIONS="--max-old-space-size=4096" pnpm run build:frontend | ||||||||||
|
|
||||||||||
| # ---- Production dependencies stage --- | ||||||||||
| FROM node:20-alpine3.19 AS prod-deps | ||||||||||
|
|
||||||||||
| RUN npm --no-update-notifier --no-fund --global install [email protected] | ||||||||||
|
|
||||||||||
| WORKDIR /app | ||||||||||
|
|
||||||||||
| COPY . . | ||||||||||
|
||||||||||
| COPY . . | |
| COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ | |
| COPY apps/*/package.json ./apps/ | |
| COPY libraries/*/package.json ./libraries/ |
ukashazia marked this conversation as resolved.
Show resolved
Hide resolved
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.