File size: 1,498 Bytes
f6a1fd1
 
 
 
 
 
6f19b05
 
 
f6a1fd1
 
 
 
 
6f19b05
 
f6a1fd1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
FROM node:20-alpine AS base

# Frontend build
FROM base AS frontend-deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN npm install -g pnpm && \
    pnpm install --frozen-lockfile

FROM base AS frontend-builder
WORKDIR /app
COPY --from=frontend-deps /app/node_modules ./node_modules
COPY . .
RUN npm install -g pnpm && \
    pnpm run build

# Backend build
FROM python:3.9-slim AS backend
WORKDIR /backend
COPY backend/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY backend .

# Final image
FROM python:3.9-slim AS runner
WORKDIR /app

ENV NODE_ENV production

# Install Node.js and wget
RUN apt-get update && apt-get install -y curl wget && \
    curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
    apt-get install -y nodejs && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

RUN addgroup --system --gid 1001 nodejs && \
    adduser --system --uid 1001 nextjs

COPY --from=frontend-builder /app/public ./frontend/public
COPY --from=frontend-builder --chown=nextjs:nodejs /app/.next/standalone ./frontend
COPY --from=frontend-builder --chown=nextjs:nodejs /app/.next/static ./frontend/.next/static
COPY --from=frontend-builder --chown=nextjs:nodejs /app/.next/cache ./frontend/.next/cache

COPY --from=backend /backend ./backend
COPY --from=backend /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages

COPY start.sh .
RUN chmod +x start.sh

EXPOSE 3000 8000

CMD ["./start.sh"]