Skip to content

Commit e88db20

Browse files
authored
add back supervisord
helps concurrency a bit
1 parent d96588a commit e88db20

File tree

1 file changed

+65
-38
lines changed

1 file changed

+65
-38
lines changed

Dockerfile.fullstack

Lines changed: 65 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ WORKDIR /app/frontend/nextjs
66

77
# Copy package files and install dependencies
88
COPY frontend/nextjs/package.json frontend/nextjs/package-lock.json* ./
9-
RUN npm install --frozen-lockfile
9+
RUN npm install --legacy-peer-deps
1010

1111
# Copy the rest of the frontend application and build it
1212
COPY frontend/nextjs/ ./
@@ -17,30 +17,32 @@ RUN npm run build
1717
########################################################################
1818
FROM python:3.13.3-slim-bookworm AS install-browser
1919

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-
2620
# 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/*
4446

4547
########################################################################
4648
# Stage 3: Python dependencies installation
@@ -55,10 +57,10 @@ COPY ./multi_agents/requirements.txt ./multi_agents/requirements.txt
5557

5658
# Install Python packages with retry logic and timeout configuration
5759
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
6264

6365
########################################################################
6466
# Stage 4: Final image with backend, frontend
@@ -67,12 +69,12 @@ FROM backend-builder AS final
6769

6870
WORKDIR /usr/src/app
6971

70-
# Install Node.js with retry logic
72+
# Install Node.js and supervisord with retry logic
7173
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/*
7678

7779
# Set backend server configuration
7880
ARG HOST=0.0.0.0
@@ -97,8 +99,33 @@ COPY --from=frontend-builder /app/frontend/nextjs/package.json ./frontend/nextjs
9799
# Ensure next.config.mjs and other necessary files are present
98100
COPY --from=frontend-builder /app/frontend/nextjs/next.config.mjs ./frontend/nextjs/next.config.mjs
99101

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

Comments
 (0)