@@ -6,7 +6,7 @@ WORKDIR /app/frontend/nextjs
6
6
7
7
# Copy package files and install dependencies
8
8
COPY frontend/nextjs/package.json frontend/nextjs/package-lock.json* ./
9
- RUN npm install --frozen-lockfile
9
+ RUN npm install --legacy-peer-deps
10
10
11
11
# Copy the rest of the frontend application and build it
12
12
COPY frontend/nextjs/ ./
@@ -17,30 +17,32 @@ RUN npm run build
17
17
########################################################################
18
18
FROM python:3.13.3-slim-bookworm AS install-browser
19
19
20
- # Configure apt for better reliability
21
- RUN echo 'Acquire::Retries "3";' > /etc/apt/apt.conf.d/80-retries && \
22
- echo 'Acquire::http::Timeout "60";' >> /etc/apt/apt.conf.d/80-retries && \
23
- echo 'Acquire::https::Timeout "60";' >> /etc/apt/apt.conf.d/80-retries && \
24
- echo 'Acquire::ftp::Timeout "60";' >> /etc/apt/apt.conf.d/80-retries
25
-
26
20
# Install Chromium, Chromedriver, Firefox, Geckodriver, and build tools in one layer
27
- RUN apt-get update \
28
- && apt-get install -y gnupg wget ca-certificates --no-install-recommends \
29
- && ARCH=$(dpkg --print-architecture) \
30
- && wget -qO - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
31
- && echo "deb [arch=${ARCH}] http://dl.google.com/linux/chrome/deb/ stable main" \
32
- > /etc/apt/sources.list.d/google-chrome.list \
33
- && apt-get update \
34
- && apt-get install -y chromium chromium-driver google-chrome-stable \
35
- && chromium --version && chromedriver --version \
36
- && apt-get install -y --no-install-recommends firefox-esr build-essential \
37
- && GECKO_ARCH=$(case ${ARCH} in amd64) echo "linux64" ;; arm64) echo "linux-aarch64" ;; *) echo "linux64" ;; esac) \
38
- && wget https://github.com/mozilla/geckodriver/releases/download/v0.36.0/geckodriver-v0.36.0-${GECKO_ARCH}.tar.gz \
39
- && tar -xvzf geckodriver-v0.36.0-${GECKO_ARCH}.tar.gz \
40
- && chmod +x geckodriver \
41
- && mv geckodriver /usr/local/bin/ \
42
- && rm geckodriver-v0.36.0-${GECKO_ARCH}.tar.gz \
43
- && rm -rf /var/lib/apt/lists/*
21
+ RUN echo 'Acquire::Retries "3";' > /etc/apt/apt.conf.d/80-retries \
22
+ && echo 'Acquire::http::Timeout "60";' >> /etc/apt/apt.conf.d/80-retries \
23
+ && echo 'Acquire::https::Timeout "60";' >> /etc/apt/apt.conf.d/80-retries \
24
+ && echo 'Acquire::ftp::Timeout "60";' >> /etc/apt/apt.conf.d/80-retries \
25
+ && apt-get update \
26
+ && apt-get install -y gnupg wget ca-certificates --no-install-recommends \
27
+ && ARCH=$(dpkg --print-architecture) \
28
+ && if [ "$ARCH" = "arm64" ]; then \
29
+ apt-get install -y chromium chromium-driver \
30
+ && chromium --version && chromedriver --version; \
31
+ else \
32
+ wget -qO - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
33
+ && echo "deb [arch=${ARCH}] http://dl.google.com/linux/chrome/deb/ stable main" \
34
+ > /etc/apt/sources.list.d/google-chrome.list \
35
+ && apt-get update \
36
+ && apt-get install -y google-chrome-stable; \
37
+ fi \
38
+ && apt-get install -y --no-install-recommends firefox-esr build-essential \
39
+ && GECKO_ARCH=$(case ${ARCH} in amd64) echo "linux64" ;; arm64) echo "linux-aarch64" ;; *) echo "linux64" ;; esac) \
40
+ && wget https://github.com/mozilla/geckodriver/releases/download/v0.36.0/geckodriver-v0.36.0-${GECKO_ARCH}.tar.gz \
41
+ && tar -xvzf geckodriver-v0.36.0-${GECKO_ARCH}.tar.gz \
42
+ && chmod +x geckodriver \
43
+ && mv geckodriver /usr/local/bin/ \
44
+ && rm geckodriver-v0.36.0-${GECKO_ARCH}.tar.gz \
45
+ && rm -rf /var/lib/apt/lists/*
44
46
45
47
########################################################################
46
48
# Stage 3: Python dependencies installation
@@ -55,10 +57,10 @@ COPY ./multi_agents/requirements.txt ./multi_agents/requirements.txt
55
57
56
58
# Install Python packages with retry logic and timeout configuration
57
59
RUN pip config set global.timeout 60 && \
58
- pip config set global.retries 3 && \
59
- pip install --upgrade pip && \
60
- pip install --no-cache-dir -r requirements.txt --upgrade --prefer-binary && \
61
- pip install --no-cache-dir -r multi_agents/requirements.txt --upgrade --prefer-binary
60
+ pip config set global.retries 3 && \
61
+ pip install --upgrade pip && \
62
+ pip install --no-cache-dir -r requirements.txt --upgrade --prefer-binary && \
63
+ pip install --no-cache-dir -r multi_agents/requirements.txt --upgrade --prefer-binary
62
64
63
65
########################################################################
64
66
# Stage 4: Final image with backend, frontend
@@ -67,12 +69,12 @@ FROM backend-builder AS final
67
69
68
70
WORKDIR /usr/src/app
69
71
70
- # Install Node.js with retry logic
72
+ # Install Node.js and supervisord with retry logic
71
73
RUN apt-get update && \
72
- apt-get install -y curl && \
73
- curl -fsSL --retry 3 --retry-delay 10 https://deb.nodesource.com/setup_20.x | bash - && \
74
- apt-get install -y nodejs && \
75
- rm -rf /var/lib/apt/lists/*
74
+ apt-get install -y curl supervisor && \
75
+ curl -fsSL --retry 3 --retry-delay 10 https://deb.nodesource.com/setup_20.x | bash - && \
76
+ apt-get install -y nodejs && \
77
+ rm -rf /var/lib/apt/lists/*
76
78
77
79
# Set backend server configuration
78
80
ARG HOST=0.0.0.0
@@ -97,8 +99,33 @@ COPY --from=frontend-builder /app/frontend/nextjs/package.json ./frontend/nextjs
97
99
# Ensure next.config.mjs and other necessary files are present
98
100
COPY --from=frontend-builder /app/frontend/nextjs/next.config.mjs ./frontend/nextjs/next.config.mjs
99
101
100
- # Start the backend and frontend servers
101
- CMD /bin/bash -c 'cd /usr/src/app; \
102
- (uvicorn main:app --host "$HOST" --port "$PORT") & \
103
- (cd frontend/nextjs && npm run start -- -p "$NEXT_PORT") & \
104
- wait'
102
+ # Create supervisord configuration
103
+ # stdout/stderr_maxbytes prevents log file rotation and ensures continuous output
104
+ RUN echo '[supervisord]' > /etc/supervisor/conf.d/supervisord.conf && \
105
+ echo 'nodaemon=true' >> /etc/supervisor/conf.d/supervisord.conf && \
106
+ echo 'user=root' >> /etc/supervisor/conf.d/supervisord.conf && \
107
+ echo 'logfile=/dev/stdout' >> /etc/supervisor/conf.d/supervisord.conf && \
108
+ echo 'logfile_maxbytes=0' >> /etc/supervisor/conf.d/supervisord.conf && \
109
+ echo '' >> /etc/supervisor/conf.d/supervisord.conf && \
110
+ echo '[program:backend]' >> /etc/supervisor/conf.d/supervisord.conf && \
111
+ echo 'command=uvicorn main:app --host %(ENV_HOST)s --port %(ENV_PORT)s' >> /etc/supervisor/conf.d/supervisord.conf && \
112
+ echo 'directory=/usr/src/app' >> /etc/supervisor/conf.d/supervisord.conf && \
113
+ echo 'autostart=true' >> /etc/supervisor/conf.d/supervisord.conf && \
114
+ echo 'autorestart=true' >> /etc/supervisor/conf.d/supervisord.conf && \
115
+ echo 'stdout_logfile=/dev/stdout' >> /etc/supervisor/conf.d/supervisord.conf && \
116
+ echo 'stdout_logfile_maxbytes=0' >> /etc/supervisor/conf.d/supervisord.conf && \
117
+ echo 'stderr_logfile=/dev/stderr' >> /etc/supervisor/conf.d/supervisord.conf && \
118
+ echo 'stderr_logfile_maxbytes=0' >> /etc/supervisor/conf.d/supervisord.conf && \
119
+ echo '' >> /etc/supervisor/conf.d/supervisord.conf && \
120
+ echo '[program:frontend]' >> /etc/supervisor/conf.d/supervisord.conf && \
121
+ echo 'command=npm run start -- -p %(ENV_NEXT_PORT)s' >> /etc/supervisor/conf.d/supervisord.conf && \
122
+ echo 'directory=/usr/src/app/frontend/nextjs' >> /etc/supervisor/conf.d/supervisord.conf && \
123
+ echo 'autostart=true' >> /etc/supervisor/conf.d/supervisord.conf && \
124
+ echo 'autorestart=true' >> /etc/supervisor/conf.d/supervisord.conf && \
125
+ echo 'stdout_logfile=/dev/stdout' >> /etc/supervisor/conf.d/supervisord.conf && \
126
+ echo 'stdout_logfile_maxbytes=0' >> /etc/supervisor/conf.d/supervisord.conf && \
127
+ echo 'stderr_logfile=/dev/stderr' >> /etc/supervisor/conf.d/supervisord.conf && \
128
+ echo 'stderr_logfile_maxbytes=0' >> /etc/supervisor/conf.d/supervisord.conf
129
+
130
+ # Start supervisord to manage both services
131
+ CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
0 commit comments