{"id":20195843,"url":"https://github.com/ralphv/selfhosted-docker-compose-framework","last_synced_at":"2026-03-19T14:29:45.482Z","repository":{"id":236411925,"uuid":"792560274","full_name":"ralphv/selfhosted-docker-compose-framework","owner":"ralphv","description":"Suggested best practices for selfhosted docker compose","archived":false,"fork":false,"pushed_at":"2024-04-26T23:54:07.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-10T17:08:13.632Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ralphv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-26T23:46:34.000Z","updated_at":"2024-04-26T23:54:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"448dfd27-65c5-4e95-9f91-17c97d8b4755","html_url":"https://github.com/ralphv/selfhosted-docker-compose-framework","commit_stats":null,"previous_names":["ralphv/selfhosted-docker-compose-framework"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ralphv/selfhosted-docker-compose-framework","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphv%2Fselfhosted-docker-compose-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphv%2Fselfhosted-docker-compose-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphv%2Fselfhosted-docker-compose-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphv%2Fselfhosted-docker-compose-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ralphv","download_url":"https://codeload.github.com/ralphv/selfhosted-docker-compose-framework/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphv%2Fselfhosted-docker-compose-framework/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30141298,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T16:58:46.102Z","status":"ssl_error","status_checked_at":"2026-03-05T16:58:45.706Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T04:19:22.696Z","updated_at":"2026-03-05T18:03:34.826Z","avatar_url":"https://github.com/ralphv.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Self-hosted docker compose framework v 0.1.0\n\n### Introduction\n* This repo is a sample framework that should cover best practices for docker compose usage.\n* This is my own evolution of using docker compose on a single server for self-hosting apps. It is my own experience, and it might not fit everyone's needs, however hopefully it will have some `good ideas` for everyone to use.\n* There is a root level `docker-compose.yaml` file that imports each app's `docker-compose.yaml`.\n\n### Requirements\n* Your docker version should be \u003e= `2.20.3`. This is when [include](https://docs.docker.com/compose/multiple-compose-files/include/) was introduced.\n\n### Getting started:\n* Search for the text: `##SETUP` to replace few placeholders with your own values.\n\n### Common environment variables\n* The root level docker-compose also defines a set of predefined environment variables:\n  * `DOCKER_COMPOSE_TZ`: Timezone\n  * `DOCKER_COMPOSE_PUID` and `DOCKER_COMPOSE_PGID` that match the system's settings for user and group ID to be used inside containers.\n  * `DOCKER_COMPOSE_RESTART_VALUE`: The default restart value.\n  * `DOCKER_COMPOSE_VOLUMES_ROOT`: The root level for volumes, you need to set this up.\n  * `DOCKER_COMPOSE_STATEFUL_VOLUMES_ROOT`: This is the directory for volumes that needs backups.\n  * `DOCKER_COMPOSE_STATEFUL_LOCKED_VOLUMES_ROOT`: This is also a directory of volumes that needs backup, but containers should be stopped before backing this up. Example: databases such as postgres need to be stopped before copying the files.\n  * `DOCKER_COMPOSE_STATELESS_VOLUMES_ROOT`: This is the directory for volumes that do not need to be backed up, usually things like cache that when deleted do not affect the state of your apps.\n  * A set of env variables that define memory limits: `DOCKER_COMPOSE_MEM_LIMIT_*`. Please check the `.env` file for the full list.\n  * A set of env variables that define CPU limits: `DOCKER_COMPOSE_CPU_*`. Please check the `.env` file for the full list.\n\n### Anatomy of an individual app\n* The individual app docker compose setup: \n  * There is a predefined `common` section at the top that makes use of the common environment variables. Use this to define common env variables, restart mode, memory and CPU limits.\n  * Defining individual memory and CPU limits on containers is a good practice for the stability of your server.\n  * Defining the service(s):\n    * Start by including the common section always\n    * Always specify the container name\n    * Specify the expose as a way to self document what this container exposes. If you are using a reverse proxy then you don't need to expose ports to your host machine. If you are defining mapped ports then expose is not needed.\n    * Try to define the properties for your services in alphabetical order to retain a common familiar order across all setups.\n      * for example `container_name` comes before `expose`. `c` before `e`\n    * Use the `main-network` always unless the app has the need to define its own network for one reason or another.\n    * Define other networks within the apps that need them.\n    * Depending on what dashboard you are using, you may want to define some labels.\n\n### The default setup\n* The default setup includes\n  * `sample-app`: This is your template for adding more apps. Each app lives in its own folder.\n  * `dozzle`: Is always a good idea to have so you can check containers metrics/logs at a glance.\n  * `watchtower`: Is defined to allow the auto update of some containers, some people prefer not to use it, in this case you can just delete the folder.\n\n### Folder structure\n* This is the suggested folder structure\n* Pick your own user root docker folder and under it, create this structure:\n```\n/[USER ROOT DOCKER FOLDER]\n ├── 🗁 selfhosted-docker-compose-framework/\n     ├── 🗋 docker-compose.yml\n     ├── 🗋 .env\n     ├── 🗋 apps/\n     └── (this is this repo)/\n ├── 🗁 volumes/                     \n     ├── 🗁 stateful/                (need to backup)\n     ├── 🗁 stateful-locked/         (need to backup, but containers must be stopped)\n     └── 🗁 stateless/               (no need to backup)\n```\n\n### Make commands\n* `make update`: pulls latest, builds and redeploys.\n* `make trivy`: Runs [trivy](https://github.com/aquasecurity/trivy). This is a security scanner.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fralphv%2Fselfhosted-docker-compose-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fralphv%2Fselfhosted-docker-compose-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fralphv%2Fselfhosted-docker-compose-framework/lists"}