This repository provides reusable Docker Compose templates for common services like Redis, Postgres, and MariaDB, along with a helper script to sync and set them up in your projects effortlessly.
- Clone or update templates from this repository in the background
- Automatically copy relevant
docker-compose.*.yamlfiles for the services you need - Merge
.envfiles from templates into one consolidated.envfile - Copy secret files from templates to your project folder
- Use a Git commit hash-based lockfile to track template versions
- Supports
--dry-run,--force, and--updateoptions in the setup script
If you want to use just one service template folder (e.g., app_template), you can download only that folder without cloning the whole repo.
- Make the downloader script executable:
chmod +x get-folder.sh- Run the script with the folder name from the repo as the argument:
./get-folder.sh app_templateThis downloads only the specified folder from the repo, moves it to your current directory, and makes the included run.sh executable.
Change into the downloaded folder and run the setup script:
cd app_template/ && ./run.shOn the first run, the script will:
- Download or update the full templates repo in the background
- Copy the necessary Docker Compose files based on your app's compose file
- Merge
.envfiles from the templates into a single.env - Copy any secret files into your project folder
After the setup finishes:
- Review and edit the generated
.envfile and secret files (e.g., update passwords or ports) - Start your containers using Docker Compose:
docker compose -f docker-compose.main.yaml up -dIf you want to refresh templates and configurations at any time, run:
./run.sh --forceTo update all used Docker images (pull the latest), run:
./run.sh --updateTo perform a dry run and see what changes would be made without applying them, run:
./run.sh --dry-runThe templates repo (fetched automatically by the script) should have this layout:
/Docker
/redis
docker-compose.redis.yaml
.env
/secrets
redis_password.txt
/postgres
docker-compose.postgres.yaml
.env
/secrets
pg_pass.txt
To keep your containers secure, the templates and setup script encourage best practices such as:
- Dropping all unnecessary capabilities (
cap_drop: all) - Running containers with read-only file systems (
read_only: true) - Using Docker security options like
security_opt: ["no-new-privileges:true"]
Please review and adjust the security settings in the individual service compose files as needed for your environment. Keeping privileges minimal helps reduce attack surface and potential risks.
- Bash shell
- Docker Compose v2 (
docker composecommand) - Git (for cloning and updating templates)
Feel free to contribute new templates or improve the sync script!