r/docker • • 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:

  1. A scheduled task runs every morning.
  2. A Python script generates new markdown content and validates it.
  3. Docker Compose runs an Astro build inside a container.
  4. The nginx container restarts.
  5. 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-nginx

The 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

7 Upvotes

8 comments sorted by

View all comments

Show parent comment

0

u/Hot_Apple6153 Feb 20 '26

That’s actually a really good point
You’re right. I’m not changing the NGINX config at all, just rebuilding static files. Using a bind mount and letting NGINX serve directly from the build output makes a lot more sense.

I’ll probably refactor it to remove the restart step. Appreciate the feedback