-
Notifications
You must be signed in to change notification settings - Fork 22
chore(linea-ens-app): refactor Dockerfile to reduce image size #362
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
+101
−49
Merged
Changes from all commits
Commits
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,54 @@ | ||
| # Dependencies (will be installed in Docker) | ||
| **/node_modules | ||
|
|
||
| # Build outputs (will be rebuilt in Docker) | ||
| **/.next | ||
| **/dist | ||
| **/build | ||
| **/out | ||
|
|
||
| # Development files | ||
| **/.gitignore | ||
| **/.env.local | ||
| **/.env.*.local | ||
|
|
||
| # IDE | ||
| **/.idea | ||
| **/.vscode | ||
| **/*.swp | ||
| **/*.swo | ||
|
|
||
| # Testing | ||
| **/coverage | ||
| **/e2e | ||
| **/test | ||
| **/*.test.* | ||
| **/*.spec.* | ||
| **/playwright | ||
| **/playwright-report | ||
|
|
||
| # Documentation | ||
| **/docs | ||
|
|
||
| # Misc | ||
| **/.DS_Store | ||
| **/Thumbs.db | ||
| **/*.log | ||
| **/npm-debug.log* | ||
| **/yarn-debug.log* | ||
| **/yarn-error.log* | ||
|
|
||
| # Archives | ||
| **/*.tar | ||
| **/*.tar.gz | ||
| **/*.tar.lz4 | ||
| **/*.zip | ||
|
|
||
| # Other packages not needed for linea-ens-app build | ||
| packages/linea-ccip-gateway | ||
| packages/linea-ens-resolver | ||
| packages/linea-ens-subgraph | ||
| packages/linea-state-verifier | ||
| packages/poh-signer-api | ||
| services | ||
|
|
||
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 |
|---|---|---|
| @@ -1,42 +1,57 @@ | ||
| FROM node:18 | ||
|
|
||
| # Install system dependencies (if necessary) | ||
| RUN apt-get update && apt-get install -y \ | ||
| libcairo2-dev \ | ||
| libpango1.0-dev \ | ||
| libjpeg-dev \ | ||
| libgif-dev \ | ||
| librsvg2-dev \ | ||
| build-essential \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
| FROM node:22-alpine AS base | ||
|
|
||
| ENV PNPM_HOME="/pnpm" | ||
| ENV PATH="$PNPM_HOME:$PATH" | ||
| RUN corepack enable | ||
|
|
||
| RUN apk add --no-cache libc6-compat python3 make g++ git \ | ||
| cairo-dev pango-dev jpeg-dev giflib-dev librsvg-dev | ||
|
|
||
| FROM base AS builder | ||
| WORKDIR /app | ||
|
|
||
| ARG NEXT_PUBLIC_ALCHEMY_KEY | ||
| ARG NEXT_PUBLIC_INFURA_KEY | ||
| ARG NEXT_PUBLIC_WC_PROJECT_ID | ||
| ARG NEXT_PUBLIC_THE_GRAPH_MAINNET_API_KEY | ||
| ARG NEXT_PUBLIC_THE_GRAPH_SEPOLIA_API_KEY | ||
|
|
||
| ENV NEXT_PUBLIC_ALCHEMY_KEY=$NEXT_PUBLIC_ALCHEMY_KEY | ||
| ENV NEXT_PUBLIC_INFURA_KEY=$NEXT_PUBLIC_INFURA_KEY | ||
| ENV NEXT_PUBLIC_WC_PROJECT_ID=$NEXT_PUBLIC_WC_PROJECT_ID | ||
| ENV NEXT_PUBLIC_THE_GRAPH_MAINNET_API_KEY=$NEXT_PUBLIC_THE_GRAPH_MAINNET_API_KEY | ||
| ENV NEXT_PUBLIC_THE_GRAPH_SEPOLIA_API_KEY=$NEXT_PUBLIC_THE_GRAPH_SEPOLIA_API_KEY | ||
| COPY . . | ||
|
|
||
| # Install pnpm and dependencies | ||
| RUN npm install -g [email protected] | ||
| RUN rm -rf node_modules | ||
| RUN pnpm config set store-dir ~/.local/share/pnpm/store | ||
| COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./ | ||
|
|
||
| COPY packages/linea-ens-app/package.json ./packages/linea-ens-app/ | ||
| COPY packages/linea-ens-contracts/package.json ./packages/linea-ens-contracts/ | ||
|
|
||
| RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile --prefer-offline | ||
|
|
||
| COPY .git ./.git | ||
alainncls marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| COPY packages/linea-ens-app/ ./packages/linea-ens-app/ | ||
| COPY packages/linea-ens-contracts/ ./packages/linea-ens-contracts/ | ||
|
|
||
| WORKDIR /app/packages/linea-ens-app | ||
| RUN pnpm build | ||
|
|
||
| # Clear Next.js cache | ||
| RUN rm -rf .next | ||
| RUN pnpm install | ||
| RUN pnpm run build | ||
| FROM node:22-alpine AS runner | ||
| WORKDIR /app | ||
|
|
||
| ENV NODE_ENV=production | ||
| ENV NEXT_TELEMETRY_DISABLED=1 | ||
|
|
||
| RUN addgroup --system --gid 1001 nodejs && \ | ||
| adduser --system --uid 1001 nextjs | ||
|
|
||
| COPY --from=builder --chown=nextjs:nodejs /app/packages/linea-ens-app/.next/standalone ./ | ||
| COPY --from=builder --chown=nextjs:nodejs /app/packages/linea-ens-app/.next/static ./packages/linea-ens-app/.next/static | ||
| COPY --from=builder --chown=nextjs:nodejs /app/packages/linea-ens-app/public ./packages/linea-ens-app/public | ||
|
|
||
| EXPOSE 3000 | ||
|
|
||
| CMD ["pnpm", "start"] | ||
| USER nextjs | ||
|
|
||
| CMD ["node", "packages/linea-ens-app/server.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
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.
Uh oh!
There was an error while loading. Please reload this page.