# Ghyma Deploy — Static Site with Health Monitoring

A "Coming Soon" static site, containerized with nginx, deployed on
[ghaymah.systems](https://deploy.ghaymah.systems), with a built-in health
check, request metrics, and a live monitoring dashboard.

Project link:
https://ghaymah1-1fea744f2ef2.hosted.ghaymah.systems/

Dashboard of project site:
https://ghaymah1-1fea744f2ef2.hosted.ghaymah.systems/dashboard/

## Project Structure

```
comingsoon-deploy/
├── Dockerfile           # Builds the nginx image
├── nginx.conf            # Adds /health and /nginx_status routes + CORS
├── monitor.py             # CLI script: polls /health every 30s, logs results
├── comingsoon/            # The static site itself (HTML/CSS/JS)
└── dashboard/
    └── index.html          # Live monitoring dashboard (served at /dashboard)
```

## What Gets Deployed

The Docker image bundles three things served by a single nginx instance:

| Path         | What it is                                              |
|--------------|----------------------------------------------------------|
| `/`          | The static "Coming Soon" site                             |
| `/dashboard` | Live monitoring UI (status, response time, request count) |
| `/health`    | Plain-text health check, returns `ok`                     |
| `/nginx_status` | nginx `stub_status` output, used for request count      |

`monitor.py` is **not** bundled in the image — it's a standalone script
meant to run on your machine (or any external host) against the deployed
URL.

## Build & Run Locally

```bash
cd comingsoon-deploy
docker build -t motazelalfy/ghyma:latest .
docker run -d -p 8080:80 --name comingsoon motazelalfy/ghyma:latest
```

Check it's working:

```bash
curl http://localhost:8080/health
curl http://localhost:8080/nginx_status
```

Open in browser:

- Site: http://localhost:8080
- Dashboard: http://localhost:8080/dashboard (auto-detects and monitors itself)

## Push to Docker Hub

```bash
docker login
docker push motazelalfy/ghyma:latest
```

## Deploy on ghaymah.systems

1. Log in at https://deploy.ghaymah.systems
2. Create a new app/service → **Deploy from image**
3. Image: `motazelalfy/ghyma:latest`
4. Port: `80`
5. Health check path (if available): `/health`
6. Deploy and wait for the public URL

## Monitor the Deployed App

Option A — open the dashboard on the live URL:

```
https://your-app.ghaymah.systems/dashboard
```

Option B — run the CLI monitor from your machine:

```bash
python monitor.py --url https://your-app.ghaymah.systems
```

Runs a check every 30 seconds by default, writes `monitor.log` and
`monitor_history.json`, and alerts after 3 consecutive failures.

Useful flags:

```bash
python monitor.py --url <URL> --interval 30 --health-path /health --once
```

## Notes / Known Limitations

- The site's PHP contact form (`comingsoon/php/contact.php`) does **not**
  work as-is — this image serves static files only, no PHP runtime.
  Adding `php-fpm` to the Dockerfile would be needed to enable it.
- `/nginx_status` is open to any origin (CORS enabled) so the dashboard can
  read it — fine for this monitoring use case, but worth restricting if the
  app ever needs tighter access control.