Skip to content

cgaspart/POC-deployer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

POC Dynamic Website Deployer

This project is a Proof of Concept (POC) for a system that dynamically deploys and serves static websites using Docker, Traefik, and a simple FastAPI backend. It automatically provisions and renews SSL certificates for each new site using Let's Encrypt.

How It Works

The architecture consists of three main services orchestrated by docker-compose:

  1. Traefik: Acts as a reverse proxy and load balancer. It routes external traffic to the appropriate service based on the requested hostname (e.g., my-site.your-domain.com). It also automatically handles SSL certificate generation via Let's Encrypt.
  2. FastAPI (api service): A simple Python API with one endpoint: /deploy/{name}. When you call this endpoint, it dynamically updates Traefik's configuration to create a new route for name.{YOUR_DOMAIN}.com, pointing it to the html-server.
  3. Nginx (html-server service): A basic web server that serves the static content found in the ./html directory. All dynamically created sites will serve content from this directory.

Key Features

  • Dynamic Routing: Deploy new sites with a single API call.
  • Automatic HTTPS: Traefik automatically obtains and renews SSL certificates from Let's Encrypt for each site.
  • Simple & Scalable: Based on a simple, containerized architecture.

Prerequisites

  • Docker and Docker Compose
  • A registered domain name (e.g., your-domain.com)
  • A server with a public IP address

Setup Instructions

1. DNS Configuration

This is the most critical step. For Traefik to route requests and for Let's Encrypt to issue certificates, you must configure your domain's DNS records.

You need to create an A record pointing to your server's public IP address for:

  1. The deployment API: deployer.{YOUR_DOMAIN}
  2. Each website you intend to create, or a wildcard for all subdomains.

Recommended Approach (Wildcard):

Create a wildcard A record to cover all subdomains:

Type Name Value (Your Server IP)
A * 123.45.67.89

This way, any subdomain (site1.your-domain.com, site2.your-domain.com, etc.) will point to your server, and you won't need to add new DNS records for each deployment.

2. Configure the Project

  1. Clone the repository.
  2. Update Domain Name: Replace all instances of {YOUR_DOMAIN}.com with your actual domain name in the following files:
    • docker-compose.yml
    • traefik/dynamic.yml
  3. Update Email: In traefik/traefik.yml, change youremail@domain.com to your email address. Let's Encrypt uses this to notify you about certificate expirations.

3. Launch the Services

Run the following command from the project's root directory:

docker-compose up -d --build

This will build the API image, pull the Traefik and Nginx images, and start all services in the background.


Usage: Deploying a New Site

To deploy a new website, make a POST request to the /deploy/{name} endpoint of the API. The {name} will become the subdomain for your new site.

For example, to create my-new-site.your-domain.com, run the following curl command:

curl -X POST https://deployer.your-domain.com/deploy/my-new-site

Traefik will detect the configuration change, create the new route, and automatically fetch an SSL certificate. Within a minute, you should be able to access https://my-new-site.your-domain.com in your browser, and it will serve the content from the ./html directory.

About

Deploy multiple website on the same server from one API call

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors