Compare commits
2 Commits
1e950823e1
...
511c37f104
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
511c37f104 | ||
|
|
3771949ba8 |
@@ -64,29 +64,43 @@ jobs:
|
|||||||
|
|
||||||
# Wait for new container to be healthy
|
# Wait for new container to be healthy
|
||||||
echo "⏳ Waiting for new container to be healthy..."
|
echo "⏳ Waiting for new container to be healthy..."
|
||||||
for i in {1..60}; do
|
HEALTH_CHECK_PASSED=false
|
||||||
|
for i in {1..90}; do
|
||||||
NEW_CONTAINER=$(docker ps -q -f name=$CONTAINER_NAME)
|
NEW_CONTAINER=$(docker ps -q -f name=$CONTAINER_NAME)
|
||||||
if [ ! -z "$NEW_CONTAINER" ]; then
|
if [ ! -z "$NEW_CONTAINER" ]; then
|
||||||
# Check health status
|
# First check HTTP health endpoint (more reliable)
|
||||||
|
if curl -f -s --max-time 5 http://localhost:$HEALTH_PORT/api/health > /dev/null 2>&1; then
|
||||||
|
echo "✅ New container is responding to HTTP health check!"
|
||||||
|
HEALTH_CHECK_PASSED=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
# Also check Docker health status as fallback
|
||||||
HEALTH=$(docker inspect $NEW_CONTAINER --format='{{.State.Health.Status}}' 2>/dev/null || echo "starting")
|
HEALTH=$(docker inspect $NEW_CONTAINER --format='{{.State.Health.Status}}' 2>/dev/null || echo "starting")
|
||||||
if [ "$HEALTH" == "healthy" ]; then
|
if [ "$HEALTH" == "healthy" ]; then
|
||||||
echo "✅ New container is healthy!"
|
echo "✅ New container is healthy (Docker health check)!"
|
||||||
|
HEALTH_CHECK_PASSED=true
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
# Also check HTTP health endpoint
|
# Show container status for debugging
|
||||||
if curl -f http://localhost:$HEALTH_PORT/api/health > /dev/null 2>&1; then
|
if [ $((i % 10)) -eq 0 ]; then
|
||||||
echo "✅ New container is responding!"
|
echo "📊 Container status: $(docker inspect $NEW_CONTAINER --format='{{.State.Status}}' 2>/dev/null || echo 'unknown')"
|
||||||
break
|
echo "📊 Health status: $HEALTH"
|
||||||
|
docker compose -f $COMPOSE_FILE logs --tail=5 portfolio 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo "⏳ Waiting... ($i/60)"
|
echo "⏳ Waiting... ($i/90)"
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
|
||||||
# Verify new container is working
|
# Verify new container is working
|
||||||
if ! curl -f http://localhost:$HEALTH_PORT/api/health > /dev/null 2>&1; then
|
if [ "$HEALTH_CHECK_PASSED" != "true" ]; then
|
||||||
echo "❌ New container failed health check!"
|
echo "❌ New container failed health check!"
|
||||||
docker compose -f $COMPOSE_FILE logs --tail=50 portfolio
|
echo "📋 Container logs:"
|
||||||
|
docker compose -f $COMPOSE_FILE logs --tail=100 portfolio
|
||||||
|
echo "📋 Container inspect:"
|
||||||
|
docker inspect $NEW_CONTAINER 2>/dev/null || echo "Container not found"
|
||||||
|
echo "📋 Testing health endpoint directly:"
|
||||||
|
curl -v http://localhost:$HEALTH_PORT/api/health || echo "Health endpoint not reachable"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ WORKDIR /app
|
|||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
|
|
||||||
|
# Install curl for health checks
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Create a non-root user
|
# Create a non-root user
|
||||||
RUN addgroup --system --gid 1001 nodejs
|
RUN addgroup --system --gid 1001 nodejs
|
||||||
RUN adduser --system --uid 1001 nextjs
|
RUN adduser --system --uid 1001 nextjs
|
||||||
|
|||||||
Reference in New Issue
Block a user