Skip to content

Commit 4ce121a

Browse files
authored
Merge pull request #7 from jeremy-feng/feat/optimize-docker-standalone
Optimize Docker image with Next.js standalone output
2 parents 4eaa755 + 6ba0462 commit 4ce121a

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ COPY --from=backend-builder /app/.venv /app/.venv
5454
COPY backend/*.py ./
5555

5656
# Copy built frontend from previous stage
57-
COPY --from=frontend-builder /app/frontend/.next ./.next
58-
COPY --from=frontend-builder /app/frontend/public ./public
59-
COPY --from=frontend-builder /app/frontend/package.json ./package.json
60-
COPY --from=frontend-builder /app/frontend/node_modules ./node_modules
57+
COPY --from=frontend-builder /app/frontend/.next/standalone /app/
58+
COPY --from=frontend-builder /app/frontend/public /app/public
59+
COPY --from=frontend-builder /app/frontend/.next/static /app/.next/static
6160

6261
# Expose ports
6362
EXPOSE 8000 3000
@@ -68,13 +67,14 @@ ENV PYTHONPATH=/app \
6867
UVICORN_PORT=8000 \
6968
PATH="/app/.venv/bin:$PATH" \
7069
VIRTUAL_ENV=/app/.venv \
71-
NODE_ENV=production
70+
NODE_ENV=production \
71+
PORT=3000
7272

7373
# Create startup script for better process management
7474
RUN echo '#!/bin/bash\n\
7575
uv run uvicorn main:app --host $UVICORN_HOST --port $UVICORN_PORT &\n\
7676
BACKEND_PID=$!\n\
77-
cd /app && PORT=3000 npx next start &\n\
77+
node /app/server.js &\n\
7878
FRONTEND_PID=$!\n\
7979
wait $BACKEND_PID $FRONTEND_PID' > /app/start.sh && chmod +x /app/start.sh
8080

frontend/next.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const withNextIntl = createNextIntlPlugin('./i18n.ts');
44

55
/** @type {import('next').NextConfig} */
66
const nextConfig = {
7+
output: 'standalone',
78
compiler: {
89
removeConsole:
910
process.env.NODE_ENV === "production"

0 commit comments

Comments
 (0)