modified docker files
This commit is contained in:
		
							parent
							
								
									0a64024d1e
								
							
						
					
					
						commit
						6a2d396afa
					
				| @ -1,7 +1,8 @@ | |||||||
| node_modules | .env | ||||||
| .next |  | ||||||
| Dockerfile | Dockerfile | ||||||
| .dockerignore | .dockerignore | ||||||
| .env | node_modules | ||||||
| .env.local | npm-debug.log | ||||||
| .env.development.local | README.md | ||||||
|  | .next | ||||||
|  | .git | ||||||
							
								
								
									
										67
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										67
									
								
								Dockerfile
									
									
									
									
									
								
							| @ -1,40 +1,59 @@ | |||||||
| # 1. Install dependencies only when needed | ##### DEPENDENCIES | ||||||
| FROM node:18-alpine AS deps | 
 | ||||||
|  | FROM --platform=linux/amd64 node:20-alpine AS deps | ||||||
|  | RUN apk add --no-cache libc6-compat openssl | ||||||
| WORKDIR /app | WORKDIR /app | ||||||
| 
 | 
 | ||||||
| # Install Prisma Client (important for runtime) | # Install Prisma Client - remove if not using Prisma | ||||||
| COPY package.json package-lock.json ./ |  | ||||||
| RUN npm ci |  | ||||||
| 
 | 
 | ||||||
| # 2. Build the app with Prisma & Next.js | COPY prisma ./ | ||||||
| FROM node:18-alpine AS builder | 
 | ||||||
|  | # Install dependencies based on the preferred package manager | ||||||
|  | 
 | ||||||
|  | COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml\* ./ | ||||||
|  | 
 | ||||||
|  | RUN \ | ||||||
|  |     if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ | ||||||
|  |     elif [ -f package-lock.json ]; then npm ci; \ | ||||||
|  |     elif [ -f pnpm-lock.yaml ]; then npm install -g pnpm && pnpm i; \ | ||||||
|  |     else echo "Lockfile not found." && exit 1; \ | ||||||
|  |     fi | ||||||
|  | 
 | ||||||
|  | ##### BUILDER | ||||||
|  | 
 | ||||||
|  | FROM --platform=linux/amd64 node:20-alpine AS builder | ||||||
|  | ARG DATABASE_URL | ||||||
|  | ARG NEXT_PUBLIC_CLIENTVAR | ||||||
| WORKDIR /app | WORKDIR /app | ||||||
| 
 |  | ||||||
| COPY . . |  | ||||||
| COPY --from=deps /app/node_modules ./node_modules | COPY --from=deps /app/node_modules ./node_modules | ||||||
|  | COPY . . | ||||||
| 
 | 
 | ||||||
| # Generate Prisma client | # ENV NEXT_TELEMETRY_DISABLED 1 | ||||||
| RUN npx prisma generate |  | ||||||
| 
 | 
 | ||||||
| # Build the app | RUN \ | ||||||
| RUN npm run build |     if [ -f yarn.lock ]; then SKIP_ENV_VALIDATION=1 yarn build; \ | ||||||
|  |     elif [ -f package-lock.json ]; then SKIP_ENV_VALIDATION=1 npm run build; \ | ||||||
|  |     elif [ -f pnpm-lock.yaml ]; then npm install -g pnpm && SKIP_ENV_VALIDATION=1 pnpm run build; \ | ||||||
|  |     else echo "Lockfile not found." && exit 1; \ | ||||||
|  |     fi | ||||||
| 
 | 
 | ||||||
| # 3. Final image | ##### RUNNER | ||||||
| FROM node:18-alpine AS runner | 
 | ||||||
|  | FROM --platform=linux/amd64 gcr.io/distroless/nodejs20-debian12 AS runner | ||||||
| WORKDIR /app | WORKDIR /app | ||||||
| 
 | 
 | ||||||
| ENV NODE_ENV=production | ENV NODE_ENV production | ||||||
| 
 | 
 | ||||||
| # Copy the built app + node_modules | # ENV NEXT_TELEMETRY_DISABLED 1 | ||||||
|  | 
 | ||||||
|  | COPY --from=builder /app/next.config.js ./ | ||||||
| COPY --from=builder /app/public ./public | COPY --from=builder /app/public ./public | ||||||
| COPY --from=builder /app/.next ./.next |  | ||||||
| COPY --from=builder /app/node_modules ./node_modules |  | ||||||
| COPY --from=builder /app/package.json ./package.json | COPY --from=builder /app/package.json ./package.json | ||||||
| COPY --from=builder /app/prisma ./prisma |  | ||||||
| 
 | 
 | ||||||
| # Include the Prisma client | COPY --from=builder /app/.next/standalone ./ | ||||||
| RUN npx prisma generate | COPY --from=builder /app/.next/static ./.next/static | ||||||
| 
 | 
 | ||||||
| # Expose port and run |  | ||||||
| EXPOSE 3000 | EXPOSE 3000 | ||||||
| CMD ["npm", "start"] | ENV PORT 3000 | ||||||
|  | 
 | ||||||
|  | CMD ["server.js"] | ||||||
| @ -8,6 +8,7 @@ const nextConfig = { | |||||||
|   reactStrictMode: true, |   reactStrictMode: true, | ||||||
|   eslint: { |   eslint: { | ||||||
|     ignoreDuringBuilds: true, |     ignoreDuringBuilds: true, | ||||||
|  |   output: "standalone", | ||||||
|   }, |   }, | ||||||
|   images: { |   images: { | ||||||
|     remotePatterns: [ |     remotePatterns: [ | ||||||
| @ -21,4 +22,5 @@ const nextConfig = { | |||||||
|   }, |   }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| export default nextConfig; | export default nextConfig; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user