{"id":22813392,"url":"https://github.com/southclaws/env2file","last_synced_at":"2025-03-30T21:46:33.387Z","repository":{"id":149829233,"uuid":"219025833","full_name":"Southclaws/env2file","owner":"Southclaws","description":"A tiny utility for turning environment variable values into files.","archived":false,"fork":false,"pushed_at":"2019-11-01T16:55:55.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-02T05:36:25.924Z","etag":null,"topics":["declarative-config","devops","docker-compose","environment-configuration","environment-variables","iac"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/Southclaws.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":"2019-11-01T16:48:40.000Z","updated_at":"2024-06-19T12:37:37.999Z","dependencies_parsed_at":null,"dependency_job_id":"0050c81e-a5dc-41a0-8e40-2dcb20633bc9","html_url":"https://github.com/Southclaws/env2file","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/Southclaws%2Fenv2file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Southclaws%2Fenv2file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Southclaws%2Fenv2file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Southclaws%2Fenv2file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Southclaws","download_url":"https://codeload.github.com/Southclaws/env2file/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246156338,"owners_count":20732390,"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":["declarative-config","devops","docker-compose","environment-configuration","environment-variables","iac"],"created_at":"2024-12-12T12:27:24.352Z","updated_at":"2025-03-30T21:46:33.342Z","avatar_url":"https://github.com/Southclaws.png","language":"Go","readme":"# env2file\n\nA tiny utility for turning environment variable values into files.\n\n```sh\ngo get github.com/Southclaws/env2file\n```\n\n```sh\ndocker pull southclaws/env2file\n```\n\n## Why\n\nSometimes you need to deploy a containerised application and it requires a file for configuration. That means you have\nto think about where that file goes, how to automate its creation and maybe even version control so you can record\nconfiguration change history.\n\nThis simplifies that by allowing you to store small-ish configuration files as environment variables in your container\nmanagement system.\n\nIt's kind of like ConfigMaps in Kubernetes.\n\n## How\n\nThis is mainly designed for deployments that use Docker Compose. The intended usage is:\n\n1. Add env2file to your compose config\n2. Mount a volume/directory to both env2file and the app that wants a file\n3. Set some environment variables on the env2file container\n4. Everything boots up, env2file creates the files, they are visible to the app, app is happy!\n\nenv2file will search for environment variables that match the following format:\n\n```env\nEF_(name|data)_(\\w+)\n```\n\nWhere the first group is either `name` or `data` and the second group is some unique name.\n\nEach \"target\" requires two variables: one for the filename and one for the contents. So if you wanted to create a file\nnamed `config.json` with some JSON in it, you'd declare two variables:\n\n```env\nEF_name_cfg=config.json\nEF_data_cfg={\"some\":\"json\"}\n```\n\nThe unique key (`cfg` in the above example) permits for as many targets as you want:\n\n```env\nEF_name_cfg=config.json\nEF_data_cfg={\"some\":\"json\"}\n\nEF_name_auth=auth.yaml\nEF_data_auth=some: yaml\n\nEF_name_other=other_stuff\nEF_data_other=my secret pizza recipe\n```\n\n```yaml\nversion: \"3.5\"\nservices:\n  someapp:\n    image: some/app\n    volumes:\n      - /shared/config:/etc/someapp/config\n  env2file:\n    image: southclaws/env2file\n    environment:\n      E2F_name_config: /config/someapp-config.json\n      E2F_data_config: |\n        {\n          \"host\": \"127.0.0.1\",\n          \"port\": 4444\n        }\n      E2F_name_clientid: /config/client_identifier\n      E2F_data_clientid: 37d060be-fb2e-11e9-99d0-645aede9143b\n    volumes:\n      - /shared/config:/config\n```\n\nIn the above example, `some/app` will see a file named `someapp-config.json` inside the `/etc/someapp/config` directory\nwith the contents:\n\n```json\n{\n  \"host\": \"127.0.0.1\",\n  \"port\": 4444\n}\n```\n\nAnd a file named `client_identifier` inside the same directory that contains simply\n`37d060be-fb2e-11e9-99d0-645aede9143b`.\n\n---\n\nYou can demo/play locally with the following docker run line:\n\n```sh\ndocker run -v$(pwd)/files:/files -e EF_name_target=/files/target.json -e EF_data_target='{\"a\":\"b\"}' southclaws/env2file\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsouthclaws%2Fenv2file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsouthclaws%2Fenv2file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsouthclaws%2Fenv2file/lists"}