mirror of
https://github.com/M4X809/list-of-lp.git
synced 2025-12-25 11:12:48 +00:00
Refactor Dockerfile and update Next.js configuration for improved build process
- Simplified the Dockerfile by consolidating dependency installation and streamlining the multi-stage build process. - Changed the base image for the builder and runner stages to `node:22-slim` for better compatibility. - Updated the Next.js configuration to remove the standalone output option and added a production start script in package.json.
This commit is contained in:
parent
a93efe5150
commit
ba4f78b27a
3 changed files with 28 additions and 34 deletions
56
Dockerfile
56
Dockerfile
|
|
@ -1,59 +1,53 @@
|
|||
# Use bun as the base image
|
||||
# Stage 1: Install dependencies with bun
|
||||
FROM oven/bun:latest AS deps
|
||||
# Install dependencies only when needed
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json next.config.ts ./
|
||||
# Simplified copy of package files
|
||||
COPY package.json bun.lock next.config.ts ./
|
||||
ARG NPM_FONT_AWESOME
|
||||
RUN bun install
|
||||
|
||||
# Install dependencies including devDependencies
|
||||
RUN bun install --frozen-lockfile
|
||||
|
||||
# Build the application
|
||||
FROM oven/bun:latest AS builder
|
||||
# Stage 2: Build Next.js with bun
|
||||
FROM node:22-slim AS builder_nextjs
|
||||
WORKDIR /app
|
||||
|
||||
# Copy dependencies and config files
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY --from=deps /app/package.json ./
|
||||
COPY --from=deps /app/next.config.ts ./
|
||||
COPY --from=deps /app/package.json ./package.json
|
||||
COPY --from=deps /app/bun.lock ./bun.lock
|
||||
COPY --from=deps /app/next.config.ts ./next.config.ts
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
ENV SKIP_ENV_VALIDATION=1
|
||||
ENV BETTER_AUTH_TELEMETRY=0
|
||||
|
||||
RUN npm run build
|
||||
# Check the build output
|
||||
RUN ls -la .next
|
||||
|
||||
# Build Next.js application
|
||||
RUN bun run build
|
||||
|
||||
# Production image
|
||||
FROM oven/bun:latest AS runner
|
||||
# Stage 4: Final runner stage
|
||||
FROM node:22-slim AS runner
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV=production
|
||||
# Copy Next.js build artifacts and dependencies
|
||||
COPY --from=builder_nextjs /app/.next ./.next
|
||||
COPY --from=builder_nextjs /app/node_modules ./node_modules
|
||||
COPY --from=builder_nextjs /app/public ./public
|
||||
COPY --from=builder_nextjs /app/package.json ./package.json
|
||||
COPY --from=builder_nextjs /app/next.config.ts ./next.config.ts
|
||||
# Copy src folder for runtime access
|
||||
COPY --from=builder_nextjs /app/src ./src
|
||||
|
||||
|
||||
# Copy Next.js build artifacts
|
||||
COPY --from=builder /app/.next/standalone ./
|
||||
COPY --from=builder /app/.next/static ./.next/static
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
COPY --from=builder /app/package.json ./
|
||||
COPY --from=builder /app/next.config.ts ./
|
||||
|
||||
ENV TZ="CET"
|
||||
ENV LANG="de_DE.UTF-8"
|
||||
ENV LANGUAGE="de_DE:de"
|
||||
ENV LC_ALL="de_DE.UTF-8"
|
||||
ENV PORT=3000
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
ENV PORT=3000
|
||||
|
||||
# Start the application
|
||||
CMD ["bun", "server.js"]
|
||||
|
||||
CMD ["npm", "run", "prod"]
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
const nextConfig: import("next").NextConfig = {
|
||||
output: "standalone",
|
||||
experimental: {
|
||||
viewTransition: true,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@
|
|||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "eslint .",
|
||||
"fetch-links": "bun run scripts/fetch-song-links.ts"
|
||||
"fetch-links": "bun run scripts/fetch-song-links.ts",
|
||||
"prod": "next start"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-svg-core": "^7.1.0",
|
||||
|
|
@ -31,7 +32,7 @@
|
|||
"@types/node": "^24.6.0",
|
||||
"@types/react": "^19.2.2",
|
||||
"@types/react-dom": "^19.2.2",
|
||||
"babel-plugin-react-compiler": "^19.1.0-rc.3",
|
||||
"babel-plugin-react-compiler": "^1.0.0",
|
||||
"eslint": "^9.36.0",
|
||||
"eslint-plugin-react-hooks": "^5.2.0",
|
||||
"globals": "^16.4.0",
|
||||
|
|
|
|||
Loading…
Reference in a new issue