{"id":15512528,"url":"https://github.com/catks/djin","last_synced_at":"2025-04-10T16:43:15.877Z","repository":{"id":41783840,"uuid":"246966463","full_name":"catks/djin","owner":"catks","description":"Djin is a make-like utility for docker, docker-compose and local commands","archived":false,"fork":false,"pushed_at":"2023-03-17T05:27:09.000Z","size":151,"stargazers_count":3,"open_issues_count":11,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T14:39:46.484Z","etag":null,"topics":["cli","devops","docker","docker-compose"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/catks.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-13T01:47:55.000Z","updated_at":"2022-09-06T20:49:33.000Z","dependencies_parsed_at":"2023-02-16T12:30:57.739Z","dependency_job_id":null,"html_url":"https://github.com/catks/djin","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catks%2Fdjin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catks%2Fdjin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catks%2Fdjin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catks%2Fdjin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/catks","download_url":"https://codeload.github.com/catks/djin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248252733,"owners_count":21072703,"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":["cli","devops","docker","docker-compose"],"created_at":"2024-10-02T09:53:42.066Z","updated_at":"2025-04-10T16:43:15.850Z","avatar_url":"https://github.com/catks.png","language":"Ruby","readme":"# Djin\n\n![](https://github.com/catks/djin/workflows/Ruby/badge.svg?branch=master)\n[![Maintainability](https://api.codeclimate.com/v1/badges/824a2e78399813543212/maintainability)](https://codeclimate.com/github/catks/djin/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/824a2e78399813543212/test_coverage)](https://codeclimate.com/github/catks/djin/test_coverage)\n\nDjin is a make-like utility for docker containers\n\n## Installation\n\nDjin is distributed as a Ruby Gem, to install simple run:\n\n    $ gem install djin\n\n### With Rbenv\n\nIf you use Rbenv you can install djin only once and create an alias in your .basrc, .zshrc, etc:\n\n#### ZSH\n    $ RBENV_VERSION=$(rbenv global) gem install djin \u0026\u0026 echo \"alias djin='RBENV_VERSION=$(rbenv global) djin'\" \u003e\u003e ~/.zshrc\n\n### Bash\n    $ RBENV_VERSION=$(rbenv global) gem install djin \u0026\u0026 echo \"alias djin='RBENV_VERSION=$(rbenv global) djin'\" \u003e\u003e ~/.bashrc\n\n## Usage\n\nTo use djin first you need to create a djin.yml file:\n\n```yaml\ndjin_version: '0.11.7'\n\ntasks:\n  # With a docker image\n  script:\n    docker:\n      image: \"ruby:2.6\"\n      run:\n        commands:\n          - \"ruby /scripts/my_ruby_script.rb\"\n        options: \"--rm -v $(pwd)/my_ruby_script.rb:/scripts/my_ruby_script.rb\"\n\n  # Using a docker-compose service\n  test:\n    docker-compose:\n      service: app\n      run:\n        commands: rspec\n        options: \"--rm\"\n    aliases: # Optional Array of strings\n      - rspec\n```\n\nYou can also set task dependencies with depends_on option:\n\n\n```yaml\ndjin_version: '0.11.7'\n\n_default_run_options: \u0026default_run_options\n  options: \"--rm\"\n\ntasks:\n  \"db:create\":\n    docker-compose:\n      service: app\n      run:\n        commands: rake db:create\n        \u003c\u003c: *default_run_options\n\n  \"db:migrate\":\n    docker-compose:\n      service: app\n      run:\n        commands: rake db:migrate\n        \u003c\u003c: *default_run_options\n\n  \"db:setup\":\n    depends_on:\n      - \"db:create\"\n      - \"db:migrate\"\n```\n\nOr mix local commands and docker/docker-compose commands:\n\n```yaml\ndjin_version: '0.11.7'\n\n_default_run_options: \u0026default_run_options\n  options: \"--rm\"\n\ntasks:\n  \"db:create\":\n    docker-compose:\n      service: app\n      run:\n        commands: rake db:create\n        \u003c\u003c: *default_run_options\n\n  \"db:migrate\":\n    docker-compose:\n      service: app\n      run:\n        commands: rake db:migrate\n        \u003c\u003c: *default_run_options\n\n  \"setup:copy_samples\":\n    local:\n      run:\n        - cp config/database.yml.sample config/database.yml\n\n  \"setup\":\n    depends_on:\n      - \"setup:copy_samples\"\n      - \"db:create\"\n      - \"db:migrate\"\n```\n\nAfter that you can run `djin {{task_name}}`, like `djin script` or `djin test`\n\n## Using Environment variables, custom variables and custom args in djin.yml tasks\n\nYou can also use environment variables using the '{{YOUR_ENV_HERE}}' syntax, like so:\n\n```yaml\ndjin_version: '0.11.7'\n\n_default_run_options: \u0026default_run_options\n  options: \"--rm\"\n\ntasks:\n  \"db:migrate\":\n    docker-compose:\n      service: app\n      run:\n        commands: ENV={{ENV}} rake db:migrate\n        \u003c\u003c: *default_run_options\n\n```\n\nOr define some variables to use in multiple locations\n```yaml\ndjin_version: '0.11.7'\n\n_default_run_options: \u0026default_run_options\n  options: \"--rm\"\n\nvariables:\n  my_ssh_user: user\n  some_host: test.local\n\ntasks:\n  \"some_host:ssh\":\n    local:\n      run:\n        - ssh {{my_ssh_user}}@{{some_host}}\n\n  \"some_host:logs\":\n    local:\n      run:\n        - ssh -t {{my_ssh_user}}@{{some_host}} 'tail -f /var/log/syslog'\n```\n\nIt's also possible to pass custom arguments to the command, which means is possible to make a djin task act like the command itself:\n\n```yaml\ndjin_version: '0.11.7'\n\n_default_run_options: \u0026default_run_options\n  options: \"--rm\"\n\ntasks:\n  \"rubocop\":\n    docker-compose:\n      service: app\n      run:\n        commands: rubocop {{args}}\n        \u003c\u003c: *default_run_options\n    aliases:\n      - lint\n\n```\n\nWith that, you can pass custom args after `--`, eg: `djin rubocop -- --parallel`, which will make djin runs `rubocop --parallel` inside the service `app`.\n\nUnder the hood djin uses [Mustache](https://mustache.github.io/), so you can use other features like conditionals: `{{#IS_ENABLE}} Enabled {{/IS_ENABLE}}` (for args use the `args?`, eg: `{{#args?}} {{args}} --and-other-thing{{/args?}}`), to see more more options you can access this [Link](https://mustache.github.io/mustache.5.html)\n\n### Reusing tasks\n\nIf you have multiple tasks with similar behavior and with small differences you can use the `include` keyword, so this:\n\n```yaml\ndjin_version: '0.11.7'\n\ntasks:\n  \"host1:ssh\":\n    local:\n      run:\n        - ssh my_user@host1.com.br\n\n  \"host1:restart\":\n    local:\n      run:\n        - ssh -t my_user@host1.com.br restart\n\n  \"host1:logs\":\n    local:\n      run:\n        - ssh -t my_user@host1.com.br tail -f /var/log/my_log\n\n  \"host2:ssh\":\n    local:\n      run:\n        - ssh my_user@host2.com.br\n\n  \"host2:restart\":\n    local:\n      run:\n        - ssh -t my_user@host2.com.br restart\n\n  \"host2:logs\":\n    local:\n      run:\n        - ssh -t my_user@host2.com.br tail -f /var/log/my_file\n\n```\n\ncan become this:\n\n```yaml\n# djin.yml\ndjin_version: '0.11.7'\n\ninclude:\n  - file: '.djin/server_tasks.yml'\n    context:\n      variables:\n        namespace: host1\n        host: host1.com\n        ssh_user: my_user\n\n  - file: '.djin/server_tasks.yml'\n    context:\n      variables:\n        namespace: host2\n        host: host2.com\n        ssh_user: my_user\n\n```\n\n\n```yaml\n# .djin/server_tasks.yml\ndjin_version: '0.11.7'\n\ntasks:\n  \"{{namespace}}:ssh\":\n    local:\n      run:\n        - ssh {{ssh_user}}@{{host}}\n\n  \"{{namespace}}:restart\":\n    local:\n      run:\n        - ssh -t {{ssh_user}}@{{host}} restart\n\n  \"{{namespace}}:logs\":\n    local:\n      run:\n        - ssh -t {{ssh_user}}@{{host}} tail -f /var/log/my_log\n```\n\nYou can also reuse tasks in some git repository, to do that you need to declare a git source and optionally a version:\n\n```yaml\ndjin_version: '0.11.7'\n\ninclude:\n  - git: 'https://github.com/catks/djin.git'\n    version: 'master'\n    file: 'examples/djin_lib/test.yml'\n    context:\n      variables:\n        namespace: 'remote:'\n\n```\n\nAfter that run `djin remote-config fetch` to fetch the repo and you can start using the tasks (All remote repos are cloned in `~/.djin/remote`)\n\nSee `djin remote-config` to learn more.\n\n### Loading custom files\n\nYou can also specify a file to be read by djin with `-f`, eg:\n\n```bash\ndjin -f my_file.yml # Returns the help for all tasks in my_file\ndjin -f my_file.yml build # Execute the build task defined in my_file.yml\n```\n\nYou can also specify multiple files to join tasks between files:\n\n```bash\n# Mix the tasks\ndjin -f my_file.yml -f my_file2.yml # Returns the help for all tasks in my_file\ndjin -f my_file.yml -f my_file2.yml build # Execute the build task defined in my_file.yml or my_file2.yml\n```\n\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, run `djin release -- {{increment_option}}` (where {{incremment_option}} can be `--patch`, `--minor` or `major`), which will change version, update the CHANGELOG.md, create a new commit, create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n\n## TODO\n\n1. Option to export tasks to Makefile\n2. djin-export docker image to create and sync makefiles\n\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/catks/djin.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatks%2Fdjin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcatks%2Fdjin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatks%2Fdjin/lists"}