-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
51 lines (40 loc) · 1.32 KB
/
Dockerfile
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
# Use Python 3.11 as the base image
FROM python:3.11-slim AS base
# Install Node.js v20.9.0, and necessary libraries for numpy
RUN apt-get update && apt-get install -y curl gnupg && \
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs
# Verify Node.js and npm installations
RUN node -v && npm -v
# Install Python packages from requirements.txt
COPY requirements.txt .
RUN pip install -r requirements.txt
# Install dependencies only when needed
FROM base AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY . .
COPY credentials.json /app
COPY --from=deps /app/node_modules ./node_modules
RUN npm run build
# RUN npm run test
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
ENV NODE_ENV production
# Create the temp directory here
RUN mkdir -p /app/temp
# Copy all necessary files from the builder stage
COPY --from=builder /app/next.config.js ./
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/src/python /app/src/python
COPY --from=builder /app/credentials.json ./
EXPOSE 3000
CMD ["npm", "start"]