File size: 1,874 Bytes
7ce37bf
 
 
 
 
 
7e4b3da
 
 
9cb412e
39f6561
 
 
 
7511c3d
 
 
7ce37bf
 
 
 
9cb412e
7e4b3da
7ce37bf
 
a4bef0b
496ca32
7ce37bf
a4bef0b
 
 
7ce37bf
 
496ca32
a4bef0b
496ca32
 
7ce37bf
a4bef0b
 
9cb412e
a4bef0b
7ce37bf
9cb412e
 
a4bef0b
7ce37bf
 
 
 
efc5df0
a4bef0b
 
7ce37bf
 
 
 
 
 
 
 
a4bef0b
 
 
 
 
 
 
 
7ce37bf
a4bef0b
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Use Node.js as base image since it's needed for the web build
FROM node:20.11-alpine3.19 AS web-builder

# Set working directory for web
WORKDIR /app/web

# Copy package files first
COPY web/package.json web/yarn.lock ./

# Configure Node to use less memory and disable telemetry
ENV NODE_OPTIONS="--max_old_space_size=2048"
ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_ENV=production

# Install ALL dependencies (including dev dependencies) needed for build
RUN yarn install --frozen-lockfile --network-timeout 300000 && \
    yarn add code-inspector-plugin

# Copy web source files
COPY web/ .

# Build web app
RUN yarn build

# Python base image for final stage
FROM python:3.10-slim-bookworm

# Install only essential dependencies
RUN apt-get update && apt-get install -y \
    nodejs \
    npm \
    --no-install-recommends && \
    rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Copy API files
COPY api/ /app/api/

# Install Python dependencies
WORKDIR /app/api
RUN pip install --no-cache-dir poetry && \
    poetry config virtualenvs.create false && \
    poetry install --no-dev

# Copy built web files from builder stage
COPY --from=web-builder /app/web/.next /app/web/.next
COPY --from=web-builder /app/web/public /app/web/public
COPY --from=web-builder /app/web/node_modules /app/web/node_modules
COPY --from=web-builder /app/web/package.json /app/web/package.json

# Set environment variables
ENV FLASK_APP=app.py \
    EDITION=SELF_HOSTED \
    DEPLOY_ENV=PRODUCTION \
    CONSOLE_API_URL=http://127.0.0.1:5001 \
    CONSOLE_WEB_URL=http://127.0.0.1:3000 \
    SERVICE_API_URL=http://127.0.0.1:5001 \
    APP_WEB_URL=http://127.0.0.1:3000 \
    NODE_ENV=production

# Expose ports
EXPOSE 3000 5001

# Copy and setup entrypoint script
COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

# Start services
CMD ["/entrypoint.sh"]