Compare commits
	
		
			3 Commits
		
	
	
		
			9b65e38542
			...
			13a389efc8
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 13a389efc8 | |||
| 4d21924690 | |||
| bb972e81ae | 
| @ -1,6 +1,5 @@ | ||||
| FASTAPI_URL="http://localhost:8000" | ||||
| 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" | ||||
|  | ||||
							
								
								
									
										62
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										62
									
								
								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 | ||||
| 
 | ||||
| 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 . . | ||||
| 
 | ||||
| # Accept build-time arguments | ||||
| ARG FASTAPI_URL | ||||
| ARG INTERNAL_API_BASE_URL | ||||
| ARG DATABASE_URL | ||||
| ARG JWT_SECRET | ||||
| # 3) Generate Prisma client (safe no-op if unused) | ||||
| RUN npx prisma generate || true | ||||
| 
 | ||||
| # Assign them to environment variables inside the image | ||||
| 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 | ||||
| # 4) Build Next.js (requires next.config.js => output: 'standalone') | ||||
| RUN npm run build | ||||
| 
 | ||||
| # ---- 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 | ||||
| 
 | ||||
| CMD ["npm", "start"] | ||||
| # (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"] | ||||
| 
 | ||||
|  | ||||
| @ -1,5 +1,6 @@ | ||||
| /** @type {import('next').NextConfig} */ | ||||
| const nextConfig = { | ||||
|     output: 'standalone', | ||||
|     reactStrictMode: false, | ||||
|     swcMinify: true, | ||||
|     eslint: { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user