Optimize Dockerfile and Next.js configuration for CI/CD efficiency. Implemented caching for npm installs, disabled React Compiler in Docker builds, and adjusted build command to use webpack. Updated GitHub Actions workflow to enhance build process with BuildKit support.

This commit is contained in:
smhk1376 committed 2026-09-24 15:05:23 +03:30
1 parent 44f4fa98e2
commit f585a5e35e
4 files changed
+17 -4

No files matched your search

+7 -1
View File
@@ -13,6 +13,8 @@ env:
NETWORK_NAME: shared_web_network NETWORK_NAME: shared_web_network
# Public hostname (Nginx Proxy Manager → this container:3000) # Public hostname (Nginx Proxy Manager → this container:3000)
PUBLIC_HOST: aut.insaight.net PUBLIC_HOST: aut.insaight.net
DOCKER_BUILDKIT: "1"
COMPOSE_DOCKER_CLI_BUILD: "1"
jobs: jobs:
deploy: deploy:
@@ -29,7 +31,11 @@ jobs:
|| docker network create "$NETWORK_NAME" || docker network create "$NETWORK_NAME"
- name: Build image - name: Build image
run: docker build -t "$IMAGE_NAME" . run: |
docker build \
--progress=plain \
-t "$IMAGE_NAME" \
.
- name: Restart container - name: Restart container
env: env:
+7 -1
View File
@@ -4,14 +4,20 @@
FROM node:22-alpine AS deps FROM node:22-alpine AS deps
WORKDIR /app WORKDIR /app
COPY package.json package-lock.json ./ COPY package.json package-lock.json ./
RUN npm ci RUN --mount=type=cache,target=/root/.npm \
npm ci
# ---- Builder ---- # ---- Builder ----
FROM node:22-alpine AS builder FROM node:22-alpine AS builder
WORKDIR /app WORKDIR /app
ENV NEXT_TELEMETRY_DISABLED=1 ENV NEXT_TELEMETRY_DISABLED=1
# Skip React Compiler in image builds (big CPU/RAM cost on self-hosted runners)
ENV DISABLE_REACT_COMPILER=1
# Cap parallelism a bit so Turbopack/webpack don't thrash low-RAM hosts
ENV NODE_OPTIONS=--max-old-space-size=3072
COPY --from=deps /app/node_modules ./node_modules COPY --from=deps /app/node_modules ./node_modules
COPY . . COPY . .
# Explicit webpack: Next 16 default Turbopack often stalls/OOMs in constrained CI
RUN npm run build RUN npm run build
# ---- Runner ---- # ---- Runner ----
+2 -1
View File
@@ -5,7 +5,8 @@ const withNextIntl = createNextIntlPlugin("./src/i18n/request.ts");
const nextConfig: NextConfig = { const nextConfig: NextConfig = {
output: "standalone", output: "standalone",
reactCompiler: true, // Babel React Compiler is heavy in Docker/CI; keep it for local `next dev`.
reactCompiler: process.env.DISABLE_REACT_COMPILER !== "1",
experimental: { experimental: {
optimizePackageImports: ["lucide-react"], optimizePackageImports: ["lucide-react"],
}, },
+1 -1
View File
@@ -4,7 +4,7 @@
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",
"build": "next build", "build": "next build --webpack",
"start": "next start", "start": "next start",
"lint": "eslint" "lint": "eslint"
}, },