The first full EC2 deployment reached the host and pulled both application images. Then Alertmanager went into a restart loop. It could see its mounted configuration path, but the process could not read the file. Prometheus was waiting for Alertmanager to become healthy, and Grafana was waiting for Prometheus. One file permission stopped the notification stack before it could start. Failed EC2 deployment
By then, I had already worked through two earlier failures. Trivy had rejected the web image after it built successfully. An access test had obtained AWS credentials and reached EC2 through Systems Manager before failing at SSH authentication. Each time, the previous stage was green and the next stage needed different evidence.
This case study covers Polo’s original EC2 deployment. The public dashboard now runs on Vercel, where the deployment configuration covers the dashboard and probe. Prometheus, Grafana, and Alertmanager were part of the EC2 stack described here. Live dashboard · Vercel configuration
I developed Polo as a hands-on DevOps project. I worked through the infrastructure, configuration, and troubleshooting with Codex assistance. Codex helped implement and test the Go probe and parts of the deployment pipeline. I used the terminal outputs, workflow runs, and live checks to understand where the system was failing.
The system I was trying to ship
Polo checks whether websites respond, how long they take to return response headers, and when their TLS certificates expire. Every 60 seconds, the Go probe fetches the monitor list from the Next.js API, checks endpoints using up to 10 concurrent workers by default, and submits the results. Each request has a 10-second default timeout. Neon PostgreSQL stores the latest result per monitor and the incident history. Prometheus stores metric samples over time.
The request path, monitoring path, and alert path connect five Compose services on one EC2 host.The stack ran on one Ubuntu t3.medium in ap-south-2, with a 30 GiB encrypted root disk and 2 GiB of swap. Terraform defined the VPC, subnet, security group, EC2, and IAM resources. A separately bootstrapped, encrypted and versioned S3 bucket stored Terraform state with locking. Nginx on the host forwarded HTTP to the dashboard over loopback. I opened the monitoring interfaces with SSH tunnels.
A successful scrape means Prometheus can reach the probe. An endpoint can still be down while the probe is reachable, and the probe can be reachable while result delivery is failing. The dashboard and verifier reflect those distinctions through target status, Prometheus up, and scan success and freshness.
Prometheus scrapes and evaluates rules every 15 seconds. A target failure must persist for 2 minutes before its alert fires. The certificate rule checks for fewer than 7 days remaining over 5 minutes, and the unreachable-probe rule waits 1 minute. Alertmanager adds a 30-second wait for a new notification group. These timers start at different stages, so notification delay depends on when the outage is first observed.
Where the release broke
For the EC2 release, GitHub Actions ran TypeScript checks, Go vet, and Go tests. It built the web and probe images, applied a Trivy gate to both, and published passing images to GitHub Container Registry. The deploy job pulled images tagged with the commit SHA, started the Compose release on EC2, and verified the running system before updating /opt/polo/current.
The three failures occurred at image publication, remote authentication, and container startup.Trivy rejected the web image
The original web image built successfully. The saved Trivy report recorded 46 HIGH findings, all under Debian OS packages. The workflow failed before publication. That pointed to the contents of the final runtime image, even though the application had compiled. Blocked workflow
We upgraded packages in the build image and moved the final stage to a non-root distroless Node runtime containing the Next.js standalone output and static assets. The image already supplied a Node entrypoint, so the Dockerfile used CMD ["server.js"]. The health check invoked Node separately and needed Node on its PATH. I checked the API, health command, and native image processing to make sure the runtime change still supported the application. Dockerfile change
The saved replacement scan recorded zero HIGH or CRITICAL findings at scan time. The same blocking policy stayed in CI. That result describes those image scans. The gates covered the two application images, and dependency updates can change future results.
The SSM session opened and SSH failed
The GitHub-hosted runner needed deployment access while inbound SSH was restricted to the administrator’s IP. GitHub OIDC obtained temporary AWS credentials, and Systems Manager carried the SSH session to EC2. The runner then had to prove it could authenticate as the server’s Linux user.
AWS authentication and the SSM connection succeeded. The SSH client reported a libcrypto loading error for the private key, followed by Permission denied (publickey). The clue was the first error. The client could reach the server but could not parse the credential it needed to present.
We replaced the GitHub secret from the complete local key file and added an early ssh-keygen -y -P "" check with output suppressed. The deploy workflow verifies the server’s ED25519 host key against authenticated EC2 console output. The access test passed in 28 seconds, including AWS identity, SSH, the bootstrap marker, Docker, and Compose. The administrator-only SSH ingress rule stayed in place. Successful access test
A private archive broke Alertmanager
The first full release got further. It uploaded the release bundle and pulled images, then Alertmanager reported permission denied on /etc/alertmanager/alertmanager.yml. The private upload used umask 077, and the extracted configuration ended up with host permissions that the non-root process inside Alertmanager could not use. Docker’s read-only bind mount protected the file from writes. The file’s own permissions still governed reads.
The fix changed access to the mounted files while preserving the private host directory boundary.We restored 0755 on monitoring directories and 0644 on public configuration files. The outer release and secrets directories stayed 0700, and the web environment file stayed 0600. File-backed secrets mounted into non-root services were made readable to those container processes within the private host directory boundary. The containers kept their existing user identities. Permission change
The failed full run lasted 3m 33s. The next full run passed in 3m 16s with all five containers healthy and functional verification complete. Those durations identify the runs. The useful comparison is which checks completed. Failed deployment · Passing deployment after the fix
What made a release count as healthy
Compose waited for the five services to become healthy, then a verifier checked that the API returned monitors, the probe reported a successful complete scan with a timestamp at most 120 seconds old, Prometheus was scraping the probe, Grafana’s health endpoint passed, and Alertmanager was ready. Only then did the release become current. Release verifier
The project exercised three endpoints, including a deliberately failing target, and recorded 86.4% Go statement coverage. I also confirmed a Discord notification, queried Prometheus from Grafana, and checked that Nginx returned the API over HTTP. Those are point-in-time checks on a single host and a small monitor set. A subsequent complete workflow also passed. Later successful workflow
One correctness detail mattered even after the stack was healthy. The API uses -1 when the probe can’t obtain a verified TLS certificate. Sending that value to Prometheus would satisfy the < 7 expiry rule. The probe preserves the API contract, removes any stale expiry sample, and emits a separate availability metric. Tests cover the missing-value path. This was preventive work against an incorrect alert. Probe tests
What I would test next
The deploy script can attempt to start the previous verified release from cached images. I would exercise that recovery path by deploying a controlled bad release, checking the previous service versions and the new result timestamps, and confirming that the workflow still reports the attempted deployment as failed. The recorded runs establish successful delivery after fixes. Recovery from an injected failure remains to be tested.
For a broader rollout of the EC2 stack, I would put HTTPS and authenticated result ingestion in place, restrict the probe’s outbound destinations, scan the third-party monitoring images, and version Grafana’s dashboard JSON. Those changes address the trust boundaries that this single-host project made visible.
View Polo’s source and deployment instructions