diff --git a/backend/Dockerfile b/backend/Dockerfile index 7db6d1c..7da1ac8 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -24,7 +24,7 @@ USER turftracker EXPOSE 5000 # Health check -HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ +HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ CMD node healthcheck.js # Start the application diff --git a/docker-compose.yml b/docker-compose.yml index 32178a6..9bf1063 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,6 +28,7 @@ services: - "traefik.http.routers.turftracker-frontend.tls.certresolver=letsencrypt" - "traefik.http.services.turftracker-frontend.loadbalancer.server.port=3000" - "traefik.docker.network=proxy" + restart: unless-stopped backend: build: @@ -62,6 +63,7 @@ services: - "traefik.http.routers.turftracker-backend.tls.certresolver=letsencrypt" - "traefik.http.services.turftracker-backend.loadbalancer.server.port=5000" - "traefik.docker.network=proxy" + restart: unless-stopped db: image: postgres:15-alpine @@ -74,6 +76,7 @@ services: - ./database/init.sql:/docker-entrypoint-initdb.d/init.sql networks: - turftracker + restart: unless-stopped # Database should not be exposed to proxy network for security volumes: diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 91d5e06..4cca375 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -23,9 +23,9 @@ USER turftracker # Expose port EXPOSE 3000 -# Health check -HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ - CMD wget --no-verbose --tries=1 --spider http://localhost:3000 || exit 1 +# Health check using Node.js script +HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ + CMD node healthcheck.js # Start the application CMD ["npm", "start"] \ No newline at end of file diff --git a/frontend/healthcheck.js b/frontend/healthcheck.js new file mode 100644 index 0000000..e1b1a8b --- /dev/null +++ b/frontend/healthcheck.js @@ -0,0 +1,33 @@ +const http = require('http'); + +const options = { + hostname: 'localhost', + port: 3000, + path: '/', + method: 'GET', + timeout: 3000 +}; + +const req = http.request(options, (res) => { + // Accept any 2xx or 3xx status code (React dev server might redirect) + if (res.statusCode >= 200 && res.statusCode < 400) { + console.log('Health check passed'); + process.exit(0); + } else { + console.log(`Health check failed with status: ${res.statusCode}`); + process.exit(1); + } +}); + +req.on('error', (err) => { + console.log('Health check error:', err.message); + process.exit(1); +}); + +req.on('timeout', () => { + console.log('Health check timeout'); + req.destroy(); + process.exit(1); +}); + +req.end(); \ No newline at end of file diff --git a/frontend/src/components/Layout/Layout.js b/frontend/src/components/Layout/Layout.js index 8ff4969..fe51a03 100644 --- a/frontend/src/components/Layout/Layout.js +++ b/frontend/src/components/Layout/Layout.js @@ -23,7 +23,6 @@ import { CalendarDaysIcon as CalendarIconSolid, ClockIcon as ClockIconSolid, CloudIcon as CloudIconSolid, - UserIcon as UserIconSolid, } from '@heroicons/react/24/solid'; import { useAuth } from '../../hooks/useAuth'; diff --git a/frontend/src/pages/Dashboard/Dashboard.js b/frontend/src/pages/Dashboard/Dashboard.js index 31489c5..359b134 100644 --- a/frontend/src/pages/Dashboard/Dashboard.js +++ b/frontend/src/pages/Dashboard/Dashboard.js @@ -8,7 +8,6 @@ import { ClockIcon, CloudIcon, PlusIcon, - ArrowTrendingUpIcon, } from '@heroicons/react/24/outline'; import { useAuth } from '../../hooks/useAuth';