Severian commited on
Commit
9b47d23
·
verified ·
1 Parent(s): 60377a9

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -7
Dockerfile CHANGED
@@ -34,6 +34,7 @@ RUN apt-get update && apt-get install -y \
34
  nginx \
35
  netcat-openbsd \
36
  net-tools \
 
37
  && rm -rf /var/lib/apt/lists/* \
38
  && pip install --no-cache-dir "poetry==${POETRY_VERSION}" \
39
  && sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \
@@ -160,11 +161,12 @@ wait_for_port() {
160
  local service=$2
161
  local max_attempts=$3
162
  local wait_time=$4
 
163
 
164
- echo "Waiting for $service on port $port..."
165
  for i in $(seq 1 $max_attempts); do
166
- if nc -z localhost $port; then
167
- echo "$service is listening on port $port"
168
  return 0
169
  fi
170
  echo "Waiting for $service (attempt $i/$max_attempts)..."
@@ -173,7 +175,7 @@ wait_for_port() {
173
 
174
  # If we get here, the service failed to start
175
  echo "=== $service Startup Failure ==="
176
- echo "Service failed to bind to port $port after $max_attempts attempts"
177
  echo "Checking process status:"
178
  ps aux | grep -i "$service" || true
179
  echo "Checking port status:"
@@ -252,7 +254,7 @@ cd /app/api && poetry run python -m gunicorn app:app \
252
 
253
  # Wait for API to be ready
254
  echo "Waiting for API server to be ready..."
255
- wait_for_port 5001 "API" 30 2
256
 
257
  # Start frontend server with logging
258
  echo "Starting frontend server..."
@@ -260,11 +262,18 @@ cd /app/web
260
  # Ensure the output log directory exists
261
  touch output.log
262
  echo "Starting Next.js server at $(date)" > output.log
 
 
 
263
  PORT=3000 node server.js >> output.log 2>&1 &
264
 
 
 
 
 
265
  # Wait for frontend to be ready with increased timeout
266
  echo "Waiting for frontend server to be ready..."
267
- if ! wait_for_port 3000 "Frontend" 60 5; then
268
  echo "Frontend server failed to start. Last 50 lines of frontend logs:"
269
  tail -n 50 /app/web/output.log
270
  exit 1
@@ -275,7 +284,7 @@ echo "Starting nginx..."
275
  nginx -g "daemon off; error_log /var/log/nginx/error.log debug;" &
276
 
277
  # Wait for nginx to be ready
278
- wait_for_port 7860 "Nginx" 30 2
279
 
280
  echo "All services are running. Starting monitoring..."
281
 
 
34
  nginx \
35
  netcat-openbsd \
36
  net-tools \
37
+ procps \
38
  && rm -rf /var/lib/apt/lists/* \
39
  && pip install --no-cache-dir "poetry==${POETRY_VERSION}" \
40
  && sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \
 
161
  local service=$2
162
  local max_attempts=$3
163
  local wait_time=$4
164
+ local host=${5:-localhost}
165
 
166
+ echo "Waiting for $service on $host:$port..."
167
  for i in $(seq 1 $max_attempts); do
168
+ if nc -z $host $port; then
169
+ echo "$service is listening on $host:$port"
170
  return 0
171
  fi
172
  echo "Waiting for $service (attempt $i/$max_attempts)..."
 
175
 
176
  # If we get here, the service failed to start
177
  echo "=== $service Startup Failure ==="
178
+ echo "Service failed to bind to $host:$port after $max_attempts attempts"
179
  echo "Checking process status:"
180
  ps aux | grep -i "$service" || true
181
  echo "Checking port status:"
 
254
 
255
  # Wait for API to be ready
256
  echo "Waiting for API server to be ready..."
257
+ wait_for_port 5001 "API" 30 2 "127.0.0.1"
258
 
259
  # Start frontend server with logging
260
  echo "Starting frontend server..."
 
262
  # Ensure the output log directory exists
263
  touch output.log
264
  echo "Starting Next.js server at $(date)" > output.log
265
+
266
+ # Configure Next.js to listen on all interfaces
267
+ export HOSTNAME="0.0.0.0"
268
  PORT=3000 node server.js >> output.log 2>&1 &
269
 
270
+ # Get container IP
271
+ CONTAINER_IP=$(hostname -i || ip route get 1 | awk '{print $7}' || echo "127.0.0.1")
272
+ echo "Container IP: $CONTAINER_IP"
273
+
274
  # Wait for frontend to be ready with increased timeout
275
  echo "Waiting for frontend server to be ready..."
276
+ if ! wait_for_port 3000 "Frontend" 60 5 "0.0.0.0"; then
277
  echo "Frontend server failed to start. Last 50 lines of frontend logs:"
278
  tail -n 50 /app/web/output.log
279
  exit 1
 
284
  nginx -g "daemon off; error_log /var/log/nginx/error.log debug;" &
285
 
286
  # Wait for nginx to be ready
287
+ wait_for_port 7860 "Nginx" 30 2 "0.0.0.0"
288
 
289
  echo "All services are running. Starting monitoring..."
290