{"id":24341324,"url":"https://github.com/veracioux/shdocker","last_synced_at":"2025-12-24T13:28:27.298Z","repository":{"id":129261028,"uuid":"453143037","full_name":"veracioux/shdocker","owner":"veracioux","description":"Don't repeat your Dockerfiles","archived":false,"fork":false,"pushed_at":"2022-12-03T12:03:50.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-18T07:16:16.767Z","etag":null,"topics":["bash","docker","shell","template-engine"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/veracioux.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":"2022-01-28T16:42:33.000Z","updated_at":"2022-02-24T22:22:37.000Z","dependencies_parsed_at":"2023-05-17T22:00:25.415Z","dependency_job_id":null,"html_url":"https://github.com/veracioux/shdocker","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veracioux%2Fshdocker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veracioux%2Fshdocker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veracioux%2Fshdocker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veracioux%2Fshdocker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/veracioux","download_url":"https://codeload.github.com/veracioux/shdocker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243104844,"owners_count":20237045,"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":["bash","docker","shell","template-engine"],"created_at":"2025-01-18T07:15:05.308Z","updated_at":"2025-12-24T13:28:22.243Z","avatar_url":"https://github.com/veracioux.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eshdocker\u003c/h1\u003e\n\u003ch2 align=\"center\"\u003eDockerfiles with shell superpowers\u003c/h2\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://aur.archlinux.org/packages/shdocker/\"\u003e \u003cimg src=\"https://img.shields.io/aur/version/shdocker?label=AUR\" alt=\"AUR\"/\u003e \u003c/a\u003e\n  \u003ca href=\"./LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/License-MIT-blueviolet\" alt=\"License\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://matrix.org/#/#shdocker:matrix.org\"\u003e\n    \u003cimg src=\"https://img.shields.io/static/v1?label=Chat\u0026message=matrix\u0026color=%23c2185b\"\u003e\n  \u003c/a\u003e\n\u003c/p\n\nShdocker is a tiny utility that allows you to write Dockerfiles with shell\nfeatures. It is basically a shell-based template engine with Dockerfiles in\nmind.\n\nShdocker is based around a `shDockerfile` which is very similar to a\nregular Dockerfile, and in many cases is exactly the same...\n\n## Use cases\n\n#### Create builds from base images that depend on environment variables\n\n**Example:**\n\n```Dockerfile\n# file: shDockerfile\nFROM \"$base:$ver\"\nRUN apk add git\n```\n\nIf you run:\n\n```sh\nbase=alpine ver=3.14.1 shdocker\n```\n\nyou will generate the following\nDockerfile:\n\n```Dockerfile\nFROM alpine:3.14.1\nRUN apk add git\n```\n\n#### Run different Dockerfile commands for each base image\n\n**Example:**\n```Dockerfile\nFROM \"$base\"\nif [ \"$base\" = \"ubuntu\" ]; then\n    RUN apt install -y git\nelif [ \"$base\" = \"alpine\" ]; then\n    RUN apk add git\nfi\n```\n\n#### Add a default tag in the `shDockerfile`\n\n**Example:**\n\n```Dockerfile\nFROM alpine\nRUN apk add --no-cache git\nTAG my-image:latest\n```\n\nBy running `shdocker .`, you will build an image tagged as\n`my-image:latest`.\n\n#### ...And much more\nYou can do anything you can imagine using shell features. **In fact, I'd be\nhonored if you shared your use cases with the community :).**\n\nLet's get you started with a more holistic example:\n\n**Example:**\n\n```Dockerfile\n[ -z \"$ver\" ] \u0026\u0026 ver=\"latest\"\n\nREQUIRE_ENV base # marks this environment variable as required\nFROM \"$base:$ver\"\n\n## Dependencies\n# (whole-line comments starting with ## are included in the output Dockerfile)\ncommon_deps=(git make)\nalpine_deps=(python3 py3-rich)\narchlinux_deps=(python python-rich)\n\nif [ \"$base\" = \"alpine\" ]; then\n    RUN apk add --no-cache \"${common_deps[@]}\" \"${alpine_deps[@]}\"\nelif [ \"$base\" = \"archlinux\" ]; then\n    RUN pacman -Sy --noconfirm \"${common_deps[@]}\" \"${archlinux_deps[@]}\"\nelse\n    echo \"Unsupported base image: $base\" \u003e\u00262\n    exit 1\nfi\n\nTAG shdocker-example:\"$base\"\n```\n\n## Installation\n\n```\nmake\nsudo make install\n```\n**Dependencies:** `bash`, `docker`.\n\nThat's it. Or you can install using your package manager (currently only ArchLinux is\nsupported via AUR).\n\n## How to use\n\nThe procedure is dead simple:\n\n- Create a shDockerfile (or adapt an existing Dockerfile into one)\n- Run `shdocker` with or without options\n- End up with an actual Dockerfile or with a built docker image\n\n##### Generate a Dockerfile from a shDockerfile\n\nJust create a `shDockerfile` and run:\n\n```\nshdocker\n```\n\nThis will automatically find the shDockerfile in the current directory and\noutput the generated Dockerfile content to stdout. You can be more specific and\nspecify the exact input (`shDockerfile`) and output (`Dockerfile`) files, like\nso:\n\n```\nshdocker -s shDockerfile -d Dockerfile\n```\n\n##### Build a docker image directly from a shDockerfile\n\nYou just have to specify a context directory to `shdocker`:\n\n```\nshdocker -s shDockerfile -d Dockerfile .\n```\n\nBecause we specified the `-d` option, a Dockerfile will be generated in the\ncurrent directory as a side-effect.\n\nActually, you can tell `shdocker` which options it should pass to `docker\nbuild`. This is valid:\n\n```\nshdocker -s shDockerfile -- -t my-tag --quiet .\n```\n\nNote that the `--` is necessary so `shdocker` doesn't think you are passing the\n`-t` and `--quiet` options to it, but to `docker build` instead.\n\n## Documentation\n\nIf you have any questions, consult the `shdocker(1)` manpage. If you can't\nfind an answer there, you can open an issue, or ask in the [matrix chat](https://matrix.org/#/#shdocker-general:matrix.org).\n\n## Contributing\n\nEveryone is free to contribute. You can simply open a PR, but I'd prefer if you\nopened an issue so we can discuss the changes first.\n\n## Projects using shdocker\n\n- [tuterm](https://github.com/veracioux/tuterm) - A better way to learn CLI programs\n\n*P.S. Please let me know about your project. I'll be glad to put it here, or you\ncan do that yourself with a PR.*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveracioux%2Fshdocker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fveracioux%2Fshdocker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveracioux%2Fshdocker/lists"}