{"id":25353916,"url":"https://github.com/aborroy/docker-init-with-templates","last_synced_at":"2025-10-29T22:30:56.408Z","repository":{"id":196489659,"uuid":"695205904","full_name":"aborroy/docker-init-with-templates","owner":"aborroy","description":"Sample implementation of generic templates for the Docker Init command.","archived":false,"fork":false,"pushed_at":"2025-02-13T13:16:46.000Z","size":85,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-13T14:26:11.334Z","etag":null,"topics":["docker","docker-init","dockercon-2023"],"latest_commit_sha":null,"homepage":"","language":"Smarty","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aborroy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-09-22T15:30:10.000Z","updated_at":"2025-02-13T13:16:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"280a73c9-6b79-4961-a471-b2db06970abc","html_url":"https://github.com/aborroy/docker-init-with-templates","commit_stats":null,"previous_names":["aborroy/docker-init-with-templates"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aborroy%2Fdocker-init-with-templates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aborroy%2Fdocker-init-with-templates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aborroy%2Fdocker-init-with-templates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aborroy%2Fdocker-init-with-templates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aborroy","download_url":"https://codeload.github.com/aborroy/docker-init-with-templates/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238902582,"owners_count":19549776,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["docker","docker-init","dockercon-2023"],"created_at":"2025-02-14T19:56:04.919Z","updated_at":"2025-10-29T22:30:51.060Z","avatar_url":"https://github.com/aborroy.png","language":"Smarty","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker Init (with templates!)\n\nSample implementation of generic templates for the [Docker Init](https://docs.docker.com/engine/reference/commandline/init/) command.\n\n## Usage\n\nDownload the binary compiled for your architecture (Linux, Windows or Mac OS) from [**Releases**](https://github.com/aborroy/docker-init-with-templates/releases).\n\n\u003e\u003e You may rename the binary to `fake-docker`, all the following samples are using this command name by default.\n\nUsing `-h` flag provides detail on the use of the different commands available.\n\n**Init**\n\n`Init` command produces Docker assets using a selected `template`.\n\n```bash\n$ ./fake-docker init -h\nInit Command\n\nUsage:\n  docker init [flags]\n  docker init [command]\n\nAvailable Commands:\n  catalog     Catalog Command\n\nFlags:\n  -d, --directory string     Local Directory containing templates to be used\n  -h, --help                 help for init\n  -o, --output string        Local Directory to write produced files\n  -p, --prompt stringArray   Property=Value list containing prompt values\n  -t, --template string      Name of the template to be used\n\nUse \"docker init [command] --help\" for more information about a command.\n```\n\n**Init Catalog**\n\n`Init Catalog` provides information relative to existing templates, reading from default inner `templates` folder or available in external `directory`\n\n```bash\n$ ./fake-docker init catalog -h\nCatalog Command\n\nUsage:\n  docker init catalog [flags]\n\nFlags:\n  -d, --directory string  Local Directory containing templates to be used\n  -h, --help              help for catalog\n  -t, --template string   Name of the template to get details\n```\n\n## Testing default templates\n\nDefault templates are provided in project's [templates](templates) folder.\n\nUse included `alfresco` template by using the `-t` flag:\n\n```bash\n$ ./fake-docker init -t alfresco\n✔ 7.4\n✔ postgres\n✔ Yes\n✔ Yes\n✔ None\nWhat is the name of your server?: localhost\n```\n\nDocker assets will be produced by default in `output` folder:\n\n```bash\n$ tree output\noutput\n├── README.md\n├── compose.yaml\n├── db\n│   └── compose.yaml\n├── legacy-ui\n│   └── compose.yaml\n├── messaging\n│   └── compose.yaml\n├── proxy\n│   └── compose.yaml\n├── repo\n│   └── compose.yaml\n├── search\n│   └── compose.yaml\n├── transform\n│   └── compose.yaml\n└── ui\n    └── compose.yaml\n```\n\nAlfresco can be tested using a regular Docker command:\n\n```bash\n$ cd output\n$ docker compose up\n```\n\n## Testing external templates\n\nThe project includes a sample for external templates definition in folder [_samples](_samples).\n\nUse included `nginx-golang-db` template from external directory by using following flags:\n\n```bash\n$ ./fake-docker init -d _samples -t nginx-golang-db\n✔ postgres\n```\n\nDocker assets will be produced by default in `output` folder:\n\n```bash\n$ tree output\noutput\n├── README.md\n├── backend\n│   ├── Dockerfile\n│   ├── go.mod\n│   ├── go.sum\n│   └── main.go\n├── compose.yaml\n├── db\n│   └── password.txt\n└── proxy\n    └── nginx.conf\n```\n\nIt can be tested using a regular Docker command:\n\n```bash\n$ cd output\n$ docker compose up --build\n```\n\n\u003e\u003e Review generated `README.md` file in `output` folder for additional testing instructions.\n\n## Creating your own template\n\nA Docker Init template is composed by a root folder that contains a set of `.tpl` files. The name of the template is given by this root folder name.\n\nTemplates, with `.tpl` extension, can be created using [text/template](https://pkg.go.dev/text/template) format.\n\nIn addition to Docker assets, a file named `prompts.yaml` must be located in template root folder. This file includes options to be gathered from user interaction or retrieved as command line parameters.\n\nEvery option must be specified as select or prompt according following syntax.\n\n### Select\n\n```yaml\n\u003cid\u003e\n    label: \u003clabel\u003e\n    multiple: true | false\n    options:\n      - \u003coption1\u003e\n      - ...\n      - \u003coptionN\u003e\n```\n\nFor instance:\n\n```yaml\nVolumes:\n  label: Which container volume method do you want to use?\n  options:\n    - None\n    - Native\n    - Bind\n```\n\nBy default, `multiple` is set to `false`. If more than one option is allowed to be chosen, add the `multiple: true` node. Selected values will be stored as a single string, separated with commas.\n\n### Prompt\n\n```yaml\n\u003cid\u003e\n    label: \u003clabel\u003e\n    default: \u003cvalue\u003e\n    password: true | false\n```\n\nFor instance:\n\n```yaml\nServer:\n  label: What is the name of your server?\n  default: localhost\n```\n\nBy default, `password` is set to `false`. If user typing should be screened as an asterisk string, add the `password: true` node.\n\n### Conditional\n\nThe prompt is enabled only when a boolean `condition` is met. The condition can include any of the previous prompts as identifier and the expression is evaluated following [goval](https://github.com/maja42/goval) rules.\n\n```yaml\n\u003cid\u003e\n    label: \u003clabel\u003e\n    [options | default]: ...\n    condition: \u003cvalue\u003e\n```\n\nFor instance:\n\n```yaml\nMessagingUser:\n   label: Choose the user name for your ActiveMQ user\n   condition: Messaging==\"Yes\" \u0026\u0026 MessagingCredentials==\"Yes\"\n   default: admin\n```\n\n### Template Folder structure\n\nAs a sample, following folder hierarchy would be defining the template `service`:\n\n```bash\nservice\n├── README.md.tpl\n├── compose.yaml.tpl\n├── prompts.yaml\n└── proxy\n    └── nginx.conf.tpl\n```\n\n\u003e\u003e Note that `prompts.yaml` is the only file that doesn't include the template extension `.tpl`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faborroy%2Fdocker-init-with-templates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faborroy%2Fdocker-init-with-templates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faborroy%2Fdocker-init-with-templates/lists"}