Update Docker Compose, Next.js config, and GitHub Actions for optimized CI/CD. Added local build notes, skipped ESLint during CI builds, and modified deployment to use prebuilt artifacts for faster image creation.

This commit is contained in:
smhk1376 committed 2026-09-24 15:25:08 +03:30
1 parent 648777c649
commit 19b75671a0
4 files changed
+84 -11

No files matched your search

+54 -9
View File
@@ -11,27 +11,72 @@ env:
IMAGE_NAME: aut-management-faculty:latest IMAGE_NAME: aut-management-faculty:latest
CONTAINER_NAME: aut-management-faculty CONTAINER_NAME: aut-management-faculty
NETWORK_NAME: shared_web_network NETWORK_NAME: shared_web_network
# Public hostname (Nginx Proxy Manager → this container:3000)
PUBLIC_HOST: aut.insaight.net PUBLIC_HOST: aut.insaight.net
# Self-hosted runner has no docker-buildx; force classic builder # Self-hosted runner has no docker-buildx; force classic builder
DOCKER_BUILDKIT: "0" DOCKER_BUILDKIT: "0"
jobs: jobs:
deploy: # Heavy Next.js compile on GitHub-hosted runners (not the InsAIght box)
name: Build and run on server build:
runs-on: [self-hosted, linux] name: Build (ubuntu)
runs-on: ubuntu-latest
steps: steps:
- name: Checkout - uses: actions/checkout@v4
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm
- name: Install & build
env:
DISABLE_REACT_COMPILER: "1"
CI_FAST_BUILD: "1"
NEXT_TELEMETRY_DISABLED: "1"
run: |
set -euo pipefail
npm ci --no-audit --no-fund
npm run build
test -f .next/standalone/server.js
- name: Stage standalone artifact
run: |
set -euo pipefail
mkdir -p prebuilt
cp -a .next/standalone prebuilt/standalone
cp -a .next/static prebuilt/static
cp -a public prebuilt/public
- uses: actions/upload-artifact@v4
with:
name: next-standalone
path: prebuilt/
retention-days: 1
# Server only packs a tiny image + restarts the container
deploy:
name: Deploy (self-hosted)
runs-on: [self-hosted, linux]
needs: build
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: next-standalone
path: prebuilt
- name: Ensure shared_web_network exists - name: Ensure shared_web_network exists
run: | run: |
docker network inspect "$NETWORK_NAME" >/dev/null 2>&1 \ docker network inspect "$NETWORK_NAME" >/dev/null 2>&1 \
|| docker network create "$NETWORK_NAME" || docker network create "$NETWORK_NAME"
- name: Build image - name: Build image from prebuilt
run: docker build -t "$IMAGE_NAME" . run: |
test -f prebuilt/standalone/server.js
docker build -f Dockerfile.prebuilt -t "$IMAGE_NAME" .
- name: Restart container - name: Restart container
env: env:
+25
View File
@@ -0,0 +1,25 @@
# Packs a pre-built Next.js standalone output — no npm / next build on the server.
# Expects build context:
# prebuilt/standalone/ ← contents of .next/standalone
# prebuilt/static/ ← contents of .next/static
# prebuilt/public/ ← public/
FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000
ENV HOSTNAME=0.0.0.0
RUN addgroup --system --gid 1001 nodejs \
&& adduser --system --uid 1001 nextjs
COPY --chown=nextjs:nodejs prebuilt/standalone/ ./
COPY --chown=nextjs:nodejs prebuilt/public ./public
COPY --chown=nextjs:nodejs prebuilt/static ./.next/static
USER nextjs
EXPOSE 3000
CMD ["node", "server.js"]
+1 -2
View File
@@ -1,5 +1,6 @@
services: services:
web: web:
# Local full build (slow). CI uses Dockerfile.prebuilt instead.
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
@@ -10,9 +11,7 @@ services:
- NODE_ENV=production - NODE_ENV=production
- PORT=3000 - PORT=3000
- HOSTNAME=0.0.0.0 - HOSTNAME=0.0.0.0
# Optional override; falls back to DATABASE_URL in src/lib/db.ts
- DATABASE_URL=${DATABASE_URL:-} - DATABASE_URL=${DATABASE_URL:-}
# No published ports. Reachable only on shared_web_network
# Nginx Proxy Manager: aut.insaight.net → http://aut-management-faculty:3000 # Nginx Proxy Manager: aut.insaight.net → http://aut-management-faculty:3000
expose: expose:
- "3000" - "3000"
+4
View File
@@ -7,6 +7,10 @@ const nextConfig: NextConfig = {
output: "standalone", output: "standalone",
// Babel React Compiler is heavy in Docker/CI; keep it for local `next dev`. // Babel React Compiler is heavy in Docker/CI; keep it for local `next dev`.
reactCompiler: process.env.DISABLE_REACT_COMPILER !== "1", reactCompiler: process.env.DISABLE_REACT_COMPILER !== "1",
// Skip lint during CI image builds (lint can still run in a separate job later).
eslint: {
ignoreDuringBuilds: process.env.CI_FAST_BUILD === "1",
},
experimental: { experimental: {
optimizePackageImports: ["lucide-react"], optimizePackageImports: ["lucide-react"],
}, },