restlessronin / dc-web-infra

docker compose infrastructure for web apps, including nginx, postgres, minio and certbot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dc-web-infra

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

Prerequisites

  • Docker
  • Docker Compose

First Time Setup

  1. Clone the repository:

    git clone --depth 1 https://github.com/restlessronin/dc-web-infra /srv/dc-web-infra
    cd /srv/dc-web-infra
  2. 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.

  3. Run the initialization script to create necessary directories:

    ./init-dirs.sh

Running the Services

  1. Start common services (Nginx and probably PostgreSQL):

    docker compose up -d nginx postgres

Renewing Lets Encrypt SSL Certificates with certbot

SSL certificates are renewed automatically via a cron job. To set up the cron job:

  1. Edit the cron jobs on the host:

    crontab -e
  2. 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.

Notes

  • Ensure that all services are on the same Docker network (infra_network) for proper communication.

About

docker compose infrastructure for web apps, including nginx, postgres, minio and certbot


Languages

Language:Shell 100.0%