update dockerfile #9
@ -2,5 +2,5 @@ FASTAPI_URL="http://localhost:8000"
 | 
				
			|||||||
INTERNAL_API_BASE_URL="http://localhost:3005"
 | 
					INTERNAL_API_BASE_URL="http://localhost:3005"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DATABASE_URL="postgresql://postgres:root@localhost:5432/rooftop?schema=public"
 | 
					DATABASE_URL="postgresql://user:pass@localhost:5432/rooftop?schema=public"
 | 
				
			||||||
JWT_SECRET="secret_key"
 | 
					JWT_SECRET="secret_key"
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										64
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										64
									
								
								Dockerfile
									
									
									
									
									
								
							@ -1,26 +1,54 @@
 | 
				
			|||||||
FROM node:18
 | 
					# syntax=docker/dockerfile:1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# ---- Build stage ----
 | 
				
			||||||
 | 
					ARG NODE_VERSION=20
 | 
				
			||||||
 | 
					FROM node:${NODE_VERSION}-slim AS builder
 | 
				
			||||||
WORKDIR /app
 | 
					WORKDIR /app
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ENV NEXT_TELEMETRY_DISABLED=1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Build-time public env hook
 | 
				
			||||||
 | 
					ARG NEXT_PUBLIC_FASTAPI_URL
 | 
				
			||||||
 | 
					ENV NEXT_PUBLIC_FASTAPI_URL=${NEXT_PUBLIC_FASTAPI_URL}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# 1) Install deps with caching
 | 
				
			||||||
 | 
					COPY package.json package-lock.json* ./
 | 
				
			||||||
 | 
					RUN npm ci
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# 2) Copy source
 | 
				
			||||||
COPY . .
 | 
					COPY . .
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Accept build-time arguments
 | 
					# 3) Generate Prisma client (safe no-op if unused)
 | 
				
			||||||
ARG FASTAPI_URL
 | 
					RUN npx prisma generate || true
 | 
				
			||||||
ARG INTERNAL_API_BASE_URL
 | 
					 | 
				
			||||||
ARG DATABASE_URL
 | 
					 | 
				
			||||||
ARG JWT_SECRET
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Assign them to environment variables inside the image
 | 
					# 4) Build Next.js (requires next.config.js => output: 'standalone')
 | 
				
			||||||
ENV FASTAPI_URL=$FASTAPI_URL
 | 
					 | 
				
			||||||
ENV INTERNAL_API_BASE_URL=$INTERNAL_API_BASE_URL
 | 
					 | 
				
			||||||
ENV DATABASE_URL=$DATABASE_URL
 | 
					 | 
				
			||||||
ENV JWT_SECRET=$JWT_SECRET
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
RUN npm install --force
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Build Next.js app
 | 
					 | 
				
			||||||
RUN npx prisma generate
 | 
					 | 
				
			||||||
RUN npm run build
 | 
					RUN npm run build
 | 
				
			||||||
 | 
					
 | 
				
			||||||
EXPOSE 3005 
 | 
					# ---- Runtime stage ----
 | 
				
			||||||
 | 
					FROM node:${NODE_VERSION}-slim AS runner
 | 
				
			||||||
 | 
					WORKDIR /app
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ENV NODE_ENV=production \
 | 
				
			||||||
 | 
					    NEXT_TELEMETRY_DISABLED=1 \
 | 
				
			||||||
 | 
					    HOSTNAME=0.0.0.0 \
 | 
				
			||||||
 | 
					    PORT=3005
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Minimal server & assets
 | 
				
			||||||
 | 
					COPY --from=builder /app/.next/standalone ./
 | 
				
			||||||
 | 
					COPY --from=builder /app/.next/static ./.next/static
 | 
				
			||||||
 | 
					COPY --from=builder /app/public ./public
 | 
				
			||||||
 | 
					COPY --from=builder /app/prisma ./prisma
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Optional (only if Prisma engine errors show up):
 | 
				
			||||||
 | 
					# COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
 | 
				
			||||||
 | 
					# COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					USER node
 | 
				
			||||||
 | 
					EXPOSE 3005
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# (Optional) healthcheck
 | 
				
			||||||
 | 
					# HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
 | 
				
			||||||
 | 
					#   CMD node -e "require('http').get('http://127.0.0.1:'+(process.env.PORT||3005)+'/_next/static/webpack/')"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CMD ["node", "server.js"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CMD ["npm", "start"]
 | 
					 | 
				
			||||||
@ -1,5 +1,6 @@
 | 
				
			|||||||
/** @type {import('next').NextConfig} */
 | 
					/** @type {import('next').NextConfig} */
 | 
				
			||||||
const nextConfig = {
 | 
					const nextConfig = {
 | 
				
			||||||
 | 
					    output: 'standalone',
 | 
				
			||||||
    reactStrictMode: false,
 | 
					    reactStrictMode: false,
 | 
				
			||||||
    swcMinify: true,
 | 
					    swcMinify: true,
 | 
				
			||||||
    eslint: {
 | 
					    eslint: {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user