Skip to content

Siva794/containerized-static-web-deployment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Containerized Static Web Deployment

Serve a static website using NGINX inside a container built with Podman/Buildah on RHEL.

What you get

  • Containerfile — the blueprint (IaC) for your image
  • index.html — example static page (replace with yours)
  • nginx.conf — points NGINX to /var/www/html
  • .containerignore — keeps the image clean
  • .github/workflows/build.yml — GitHub Actions to build (and optionally push) the image
  • Makefile — handy make build / make run shortcuts

Run locally with Podman

podman build -t static-site:latest -f Containerfile .
podman run --rm -p 8080:80 static-site:latest
# open http://localhost:8080

Tip: Podman is daemonless and works rootless on RHEL. Mapping 8080:80 exposes the container's port 80 on your host's port 8080.


Create a GitHub repository (first time)

  1. Go to GitHub → New repository → name it containerized-static-web-deployment.
  2. Choose Public (or Private) → Create repository.
  3. Upload files (Add file → Upload files) and drop everything from this folder.
  4. Commit the changes (green Commit button).

From now on, every change you push is version-controlled.


Enable GitHub Actions (optional but recommended)

This repo ships with a ready workflow: .github/workflows/build.yml.

  • On GitHub, open the Actions tab — enable workflows if prompted.
  • Push/commit to main — it will build your container image.
  • If you also want to publish to GitHub Container Registry (GHCR):
    1. Create a Personal Access Token (classic) with write:packages scope.
    2. In your repo, go to Settings → Secrets and variables → Actions → New repository secret:
      • GHCR_USERNAME — your GitHub username
      • GHCR_TOKEN — the token you created
    3. Edit image_name in the workflow if you want a different name.

After a successful run, pull the image anywhere with:

podman pull ghcr.io/<your-username>/static-site:latest
podman run --rm -p 8080:80 ghcr.io/<your-username>/static-site:latest

Common tweaks

  • Replace index.html with your site files. Keep the same folder structure; the Containerfile copies everything into /var/www/html.
  • Want a different port on your machine? Change -p 8080:80 to -p 3000:80 (host:container).

Why this approach? (Short)

  • Isolation & security: web server is jailed inside the container.
  • Portability: same image runs everywhere.
  • Reproducibility: the Containerfile is your single source of truth.

Troubleshooting

  • Port already in use: choose another host port, e.g. -p 9000:80.
  • Permission issues on rootless Podman: stick to port mapping (host high port → container 80) as shown.
  • SELinux denials: keep site files inside the image (as we do), not bind-mounted, to avoid extra labeling steps.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published