Docker compose based infrastructure for web applications, including common services like nginx, postgres, and certbot. A blueprint for per-app compose files and environment settings can be used to add additional apps.
This project was created in collaboration with GPT-4o
- Docker
- Docker Compose
-
Clone the repository:
git clone --depth 1 https://github.com/restlessronin/dc-web-infra /srv/dc-web-infra cd /srv/dc-web-infra
-
Copy the sample environment files and configure:
cp .env.template .env cp postgres.env.template postgres.env
Edit
postgres.env
to set your superuser database user, password, and other configuration. -
Run the initialization script to create necessary directories:
./init-dirs.sh
-
Start common services (Nginx and probably PostgreSQL):
docker compose up -d nginx postgres
SSL certificates are renewed automatically via a cron job. To set up the cron job:
-
Edit the cron jobs on the host:
crontab -e
-
Add a cron job to run the renewal and reload script twice a day:
0 0,12 * * * /srv/dc-web-infra/renew-reload.sh
This cron job will:
- Run the Certbot container to renew certificates.
- Reload the Nginx configuration to apply the renewed certificates.
- Ensure that all services are on the same Docker network (
infra_network
) for proper communication.