{"id":28176715,"url":"https://github.com/omercsp/runenv","last_synced_at":"2026-05-04T09:32:38.846Z","repository":{"id":218207087,"uuid":"343951496","full_name":"omercsp/runenv","owner":"omercsp","description":"Simple bash script for running different container based environment according to the current working directory.","archived":false,"fork":false,"pushed_at":"2021-09-13T17:29:52.000Z","size":18,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-10T04:37:14.058Z","etag":null,"topics":["bash","build","containers","docker","linux","podman"],"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/omercsp.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,"zenodo":null}},"created_at":"2021-03-03T00:24:17.000Z","updated_at":"2025-05-27T21:51:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"97032f4d-ed64-4491-a190-a4248762cb7c","html_url":"https://github.com/omercsp/runenv","commit_stats":null,"previous_names":["omercsp/runenv"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/omercsp/runenv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omercsp%2Frunenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omercsp%2Frunenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omercsp%2Frunenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omercsp%2Frunenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omercsp","download_url":"https://codeload.github.com/omercsp/runenv/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omercsp%2Frunenv/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32601527,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"online","status_checked_at":"2026-05-04T02:00:06.625Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["bash","build","containers","docker","linux","podman"],"created_at":"2025-05-16T00:19:23.035Z","updated_at":"2026-05-04T09:32:38.828Z","avatar_url":"https://github.com/omercsp.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Run Environment Script\n\n## What is this?\n\nA tool to automatically run the correct container, with the correct arguments and the correct command according to the directory it is invoked from. The actual command to execute in the container is passed as CLI argument or set in a configuration file (with many other possible settings).\n\n## What for?\n\nThe motivation for this tool came from my need to build different projects, using different tool-chains, for different platforms. Like many others, I used containers as build platforms for that reason, but still had to keep track keep track of where I am, what image I need to run, with what settings in order to build for the correct target. (The terms 'build' and 'target' are used here as this script was originally written to help building project using `make`, but the command can be anything).\n\nFor example, assume a gcc C++ project that need to be built for a CentOS Linux with specific version using `make`. Build containers based on the target platform (CentOS, in this case) can help here. But still I need to remember how exactly this is done every time I work on this project. Now add to it another project for a different platform and a different build command (say, `scons`). Now there's a need to keep track of on which project is built, which platform (container) to use for it, and which command to run it.\n\nEnter the `runenv.sh` script.\n\n\n## How does it help?\n\nThe script uses a configuration file named `.runenv.conf` that defines all that there is to be defined running in this particular folder. Once set, no need to remember anything anymore. Just invoke the `runenv.sh` script, and everything is ran as expected. This allows consistency over all projects. Instead of running specific containers and scripts for each project, the same method and configuration is used. It also allows to run a different commands in the same environment (See the `RE_CMD` setting and explanation below) which is useful.\n\n## Is this new?\n\nProbably not. Didn't check. Projects like this one are likely to exist somewhere, and some people might find this redundant, but it works for me and might work for anyone who looks for a (relatively) simple local solution.\n\n## How do I work with it?\n\n1. Place the `runenv.sh` somewhere in you path (say,  `${HOME}/.local/bin`)\n2. Create a configuration file in the desired project folder - copy the `dot-runenv.conf.skel` to your project folder as `.runenv.conf`, and edit the file according to your needs.\n\nAnd you are set to go. Now all that needs to be done is to run `runenv.sh` and the right image with the right command is executed. Repeat step 2 for every project/folder you need to have it's own container/command/setting for. Overriding the command in set in the configuration file is done by running `runenv.sh \u003cCMD\u003e`.\n\n### Example\n\nFollowing the previous example, assume that under `/opt/project` folder, there's a small C++ project to be built with a container from an image named `localhost:mybuilder`. To run this configuration correctly one needs to run the container with all kind of setting to make the build as expected:\n\n1. The image\n2. Volume mapping\n3. Working directory\n4. etc.\n\nSo if the command is simple, it might look something like this:\n\n```\nproject $ podman run -it -v $(pwd):$(pwd) -w $(pwd) localhost/mybuilder:latest make\nBuilding 'a.out'\nCXX\tmain.o\nLD\ta.out\nproject $\n```\n\nIf the run command is more complex, this might get exhausting. Using `runenv.sh` is there to simplify this process.\n\nFirst, create a `.runenv.conf` file in the project directory, then populate it with the appropriate settings (see the `dot-runenv.conf.skel` file for settings description):\n\n```bash\nRE_IMAGE=localhost/mybuilder:latest\nRE_CMD=make\nRE_VOL_MAPPING=$(pwd):$(pwd)\nRE_USE_CUR_CWD=1\n```\n\nThen, just run the `runenv.sh`:\n\n```\nproject $ runenv.sh\n __             ___\n|__) |  | |\\ | |__  |\\ | \\  /\n|  \\ \\__/ | \\| |___ | \\|  \\/\n\nConfiguration file: /opt/project/.runenv.conf\nTool: podman\nImage: localhost/mybuilder:latest\nRun flags: -w=/opt/project\nVolume: /opt/project:/opt/project\nCommand: 'make'\n==============================================================================\nBuilding 'a'\nCC main.o\nLD a\n==============================================================================\nDone!\nproject $\n\n```\n\nNow you can just build the project with the right container, the right setting and the right command without the need to remember anything. With many folders like this one, as well as folder which aren't containers based this can be handy. Always run you command through the script, and the correct environment will be set for it.\n\n## A few notes about configuration\n\nThe full configuration documentation is inside `dot-runenv.conf.skel`, but some things are worth mentioning regarding the script behavior\n\n1. All configuration files are actually bash scripts sourced by the script, so keep the format as `\u003cSETTING\u003e=\u003cVALUE\u003e`. No spaces around the assignment operator, or it won't work. This also means bash internals and program execution can be used and added here.\n2. The script first attempts to read a global configuration file `${HOME}/.config/.runenv.conf`.\n3. Afterwards the script attempts to search for a `.runenv.sh` on every folder from the current working directory all the way up to root. If one is found, the search is stopped. Settings found in this configuration file override those from the global configuration file.\n4. Other then the command setting (`RE_CMD`), all other settings can be overridden by environment variables with a `_` prefix. So setting `_RE_IMAGE` will override the `RE_IMAGE` found in any of the configuration files. This is useful for debugging and to overriding from from IDEs and such.\n5. The command setting `RE_CMD` is overridden by the tool CLI arguments, so `runenv.sh echo \"foo\"` will override whatever the configuration files defined as `RE_CMD` with `echo \"foo\"`.\n\n## Supported systems\n\nI wrote this tool for me, so it only tested on Linux - Fedora, in my case - with `podman` as a container running tool but it should be compatible to, or easy to port to, any docker-like tool in a `bash` supported environment. There's a setting for changing the running tool, but I have yet to test it.\n\nDocker based configuration will probably need a user ID and group ID run/exec settings.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomercsp%2Frunenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomercsp%2Frunenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomercsp%2Frunenv/lists"}