3 Commits

Author SHA1 Message Date
c62ee5f699 🔧 Fix health checks: Use IPv4 address + Add debugging
Some checks failed
Release - Northern Thailand Ping River Monitor / Create Release (push) Successful in 6s
Security & Dependency Updates / License Compliance (push) Successful in 16s
Release - Northern Thailand Ping River Monitor / Test Release Build (3.12) (push) Successful in 22s
Release - Northern Thailand Ping River Monitor / Test Release Build (3.9) (push) Successful in 24s
Security & Dependency Updates / Dependency Security Scan (push) Successful in 32s
Security & Dependency Updates / Check for Dependency Updates (push) Successful in 27s
Security & Dependency Updates / Code Quality Metrics (push) Successful in 26s
Release - Northern Thailand Ping River Monitor / Test Release Build (3.10) (push) Successful in 23s
Release - Northern Thailand Ping River Monitor / Test Release Build (3.11) (push) Successful in 19s
Security & Dependency Updates / Security Summary (push) Successful in 8s
Release - Northern Thailand Ping River Monitor / Build Release Images (push) Successful in 7m46s
Release - Northern Thailand Ping River Monitor / Security Scan (push) Successful in 4s
Release - Northern Thailand Ping River Monitor / Test Release Deployment (push) Failing after 3m24s
Release - Northern Thailand Ping River Monitor / Notify Release (push) Successful in 1s
🌐 Network Fix:
- Change localhost to 127.0.0.1 for all health check URLs
- Prevents IPv6 resolution issues in CI environment
- Ensures consistent IPv4 connectivity to container

🔍 Debugging Improvements:
- Check if container is running with docker ps
- Show recent container logs before health checks
- Better troubleshooting information for failures

📋 Updated Endpoints:
- http://127.0.0.1:8080/health
- http://127.0.0.1:8080/docs
- http://127.0.0.1:8080/stations
- http://127.0.0.1:8080/metrics

 Should resolve curl connection failures to localhost
2025-08-13 12:16:13 +07:00
cd59236473 🔧 Fix health checks: Use IPv4 address + Add debugging
🌐 Network Fix:
- Change localhost to 127.0.0.1 for all health check URLs
- Prevents IPv6 resolution issues in CI environment
- Ensures consistent IPv4 connectivity to container

🔍 Debugging Improvements:
- Check if container is running with docker ps
- Show recent container logs before health checks
- Better troubleshooting information for failures

📋 Updated Endpoints:
- http://127.0.0.1:8080/health
- http://127.0.0.1:8080/docs
- http://127.0.0.1:8080/stations
- http://127.0.0.1:8080/metrics

 Should resolve curl connection failures to localhost
2025-08-13 12:15:36 +07:00
18f77530ec Fix Docker container Python dependencies issue
Some checks failed
Release - Northern Thailand Ping River Monitor / Create Release (push) Successful in 6s
Security & Dependency Updates / Dependency Security Scan (push) Successful in 37s
Security & Dependency Updates / License Compliance (push) Successful in 17s
Security & Dependency Updates / Code Quality Metrics (push) Has been cancelled
Security & Dependency Updates / Check for Dependency Updates (push) Has been cancelled
Security & Dependency Updates / Security Summary (push) Has been cancelled
Release - Northern Thailand Ping River Monitor / Test Release Build (3.11) (push) Has been cancelled
Release - Northern Thailand Ping River Monitor / Test Release Build (3.12) (push) Has been cancelled
Release - Northern Thailand Ping River Monitor / Test Release Build (3.9) (push) Has been cancelled
Release - Northern Thailand Ping River Monitor / Build Release Images (push) Has been cancelled
Release - Northern Thailand Ping River Monitor / Security Scan (push) Has been cancelled
Release - Northern Thailand Ping River Monitor / Test Release Deployment (push) Has been cancelled
Release - Northern Thailand Ping River Monitor / Notify Release (push) Has been cancelled
Release - Northern Thailand Ping River Monitor / Test Release Build (3.10) (push) Has been cancelled
Dockerfile Fixes:
- Copy Python packages to /home/appuser/.local instead of /root/.local
- Create appuser home directory before copying packages
- Update PATH to use /home/appuser/.local/bin
- Set proper ownership of .local directory for appuser
- Ensure appuser has access to installed Python packages

 Problem Solved:
- Container was failing with 'ModuleNotFoundError: No module named requests'
- appuser couldn't access packages installed in /root/.local
- Python dependencies now properly accessible to non-root user

 Docker container should now start successfully with all dependencies
2025-08-13 11:50:03 +07:00
2 changed files with 225 additions and 221 deletions

View File

@@ -3,16 +3,16 @@ name: Release - Northern Thailand Ping River Monitor
on: on:
push: push:
tags: tags:
- 'v*.*.*' - "v*.*.*"
workflow_dispatch: workflow_dispatch:
inputs: inputs:
version: version:
description: 'Release version (e.g., v3.1.3)' description: "Release version (e.g., v3.1.3)"
required: true required: true
type: string type: string
env: env:
PYTHON_VERSION: '3.11' PYTHON_VERSION: "3.11"
REGISTRY: git.b4l.co.th REGISTRY: git.b4l.co.th
IMAGE_NAME: b4l/northern-thailand-ping-river-monitor IMAGE_NAME: b4l/northern-thailand-ping-river-monitor
# GitHub token for better rate limits and authentication # GitHub token for better rate limits and authentication
@@ -71,7 +71,7 @@ jobs:
needs: create-release needs: create-release
strategy: strategy:
matrix: matrix:
python-version: ['3.9', '3.10', '3.11', '3.12'] python-version: ["3.9", "3.10", "3.11", "3.12"]
steps: steps:
- name: Checkout code - name: Checkout code
@@ -161,8 +161,6 @@ jobs:
with: with:
token: ${{ secrets.GITEA_TOKEN}} token: ${{ secrets.GITEA_TOKEN}}
# Test release deployment locally # Test release deployment locally
deploy-release: deploy-release:
name: Test Release Deployment name: Test Release Deployment
@@ -213,9 +211,16 @@ jobs:
echo "🔍 Running health checks against local container..." echo "🔍 Running health checks against local container..."
# Check if container is running
docker ps | grep ping-river-monitor-test || echo "⚠️ Container not found in docker ps"
# Check container logs for any startup issues
echo "📋 Recent container logs:"
docker logs --tail 10 ping-river-monitor-test || true
# Wait for the application to be ready # Wait for the application to be ready
for i in {1..12}; do for i in {1..12}; do
if curl -f http://localhost:8080/health; then if curl -f http://127.0.0.1:8080/health; then
echo "✅ Health endpoint responding" echo "✅ Health endpoint responding"
break break
else else
@@ -226,10 +231,10 @@ jobs:
# Test API endpoints # Test API endpoints
echo "🧪 Testing API endpoints..." echo "🧪 Testing API endpoints..."
curl -f http://localhost:8080/health || exit 1 curl -f http://127.0.0.1:8080/health || exit 1
curl -f http://localhost:8080/docs || exit 1 curl -f http://127.0.0.1:8080/docs || exit 1
curl -f http://localhost:8080/stations || exit 1 curl -f http://127.0.0.1:8080/stations || exit 1
curl -f http://localhost:8080/metrics || exit 1 curl -f http://127.0.0.1:8080/metrics || exit 1
echo "✅ All health checks passed!" echo "✅ All health checks passed!"
@@ -249,8 +254,6 @@ jobs:
echo "Status: Container tested successfully" echo "Status: Container tested successfully"
echo "Ready for production deployment" echo "Ready for production deployment"
# Notify stakeholders # Notify stakeholders
notify: notify:
name: Notify Release name: Notify Release

View File

@@ -22,26 +22,27 @@ FROM python:3.11-slim
# Set working directory # Set working directory
WORKDIR /app WORKDIR /app
# Install runtime dependencies # Install runtime dependencies and create user
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
wget \ wget \
curl \ curl \
&& rm -rf /var/lib/apt/lists/* \ && rm -rf /var/lib/apt/lists/* \
&& groupadd -r appuser && useradd -r -g appuser appuser && groupadd -r appuser && useradd -r -g appuser appuser \
&& mkdir -p /home/appuser/.local
# Copy Python packages from builder stage # Copy Python packages from builder stage
COPY --from=builder /root/.local /root/.local COPY --from=builder /root/.local /home/appuser/.local
# Copy application code # Copy application code
COPY . . COPY . .
# Create logs directory and set permissions # Create logs directory and set permissions
RUN mkdir -p logs && chown -R appuser:appuser /app RUN mkdir -p logs && chown -R appuser:appuser /app /home/appuser/.local
# Set environment variables # Set environment variables
ENV PYTHONUNBUFFERED=1 ENV PYTHONUNBUFFERED=1
ENV TZ=Asia/Bangkok ENV TZ=Asia/Bangkok
ENV PATH=/root/.local/bin:$PATH ENV PATH=/home/appuser/.local/bin:$PATH
# Switch to non-root user # Switch to non-root user
USER appuser USER appuser