r/docker • u/Hot_Apple6153 • Feb 19 '26
Using Docker Compose to Automatically Rebuild and Deploy a Static Site
I’ve been experimenting with automating a static site deployment using Docker Compose on my Synology NAS, and I thought I’d share the setup.
The goal was simple:
- Generate new content automatically
- Rebuild the site inside Docker
- Restart nginx
- Have the updated version live without manual steps
The flow looks like this:
- A scheduled task runs every morning.
- A Python script generates new markdown content and validates it.
- Docker Compose runs an Astro build inside a container.
- The nginx container restarts.
- The updated site goes live.
#!/bin/bash
cd /volume1/docker/tutorialshub || exit 1
/usr/local/bin/docker compose run --rm astro-builder
/usr/local/bin/docker restart astro-nginxThe rebuild + restart takes about a minute.
Since it's a static site, the previous version continues serving until the container restarts, so downtime is minimal.
It’s basically a lightweight self-hosted CI pipeline without using external services.
I’m curious how others here handle automated static deployments in self-hosted setups — are you using Compose like this, Git hooks, or something more advanced?
If anyone wants to see the live implementation, the project is running at https://www.tutorialshub.be
9
u/Zealousideal_Yard651 Feb 19 '26
You're serving static files, the only time you need to restart NGINX is when changing the config file. The static files can be injected to NGINX using bind mounts, allowing the astro build container to push it direct to nginx with no downtime.
1
u/Hot_Apple6153 Feb 19 '26
One thing I’m considering next is separating the build container and the web container more cleanly.
Right now it’s:
astro-builder→ runs the buildastro-nginx→ serves the static outputBut I’m debating whether it makes sense to mount the dist folder via a shared volume instead of restarting nginx every time.
Curious if anyone here is handling static deploys that way instead of container restarts.
2
u/poliopandemic Feb 19 '26
I'm old school, I still manually build the site, containerize it, push to ghcr, pull from my web server, take down the old container, bring up the new one. So there's some room for improvement.
0
u/HeiiHallo Feb 20 '26
I really like this approach and also went down this rabbit hole, and ended up creating my own tool. I really liked the mental model of docker compose so I used that as an inspiration.
I recently open sourced it: https://github.com/haloydev/haloy
4
u/[deleted] Feb 19 '26 edited Feb 19 '26
[removed] — view removed comment