Package: dip
dipInstall CLIs using docker-compose.InstallationInstall via Homebrew:brewtapamancevice/tap
brewinstallamancevice/tap/dipOr usepip:pipinstalldipSimple UsageWrite a CLI in whatever language you chooseCreate aDockerfilethat installs your CLI applicationWrite adocker-compose.ymlfile that builds the image and defines the run-time configurationRundip install <service> .to install the service as an executable commandRundip uninstall <service> .to remove the executable from the file systemmkdirexamplecdexample
touchdocker-compose.yml# Edit docker-compose.yml to include 'dipex' service...dipinstalldipex.Tracking a git remoteFollow steps 1-3 aboveCommit these files to a branch on a git remote (eg.origin/main)Rundip install <service> . --remote <remote>/<branch>to install the service as an executable command that will track changes todocker-compose.ymlon the supplied remote/branchRundip uninstall <service>to remove the executable from the file systemgitclonegit@github.com:owner/repo-with-docker-compose.gitcdrepo-with-docker-compose
dipinstalldipex.--remoteorigin/mainIf a CLI is installed with the--remoteflag, any differences between the local and remotedocker-compose.ymlfiles will trigger a prompt asking if the user wishes to upgrade (git pull).If the user declines to upgrade he/she must resolve the conflict before continuing.Alternatively, use the--sleepoption to show the user the diff, then sleep for the provided time (in seconds) instead of waiting on user input.dipinstalldipex.--remoteorigin/main--sleep10Upgrading from a git remoteFollow the steps above to install your CLI with a remoteIf the remote moves ahead of the local, you will see a warning when executing CLI commandsusedip upgrade <service>to pull changes from the remoteInstalling with ENV variablesUse the--envoption to install the CLI with an environment variable set. Use the--secretoption to enter the environment variable in an interactive prompt where the input is hidden.Ex.dipinstallmycli/path/to/project\--remoteorigin/main\--envFIZZ=BUZZWill generate an executable with the namemycli, monitor theorigin/mainremote/branch for changes and set theENVvariableFIZZto the valueBUZZeach time themycliis executed.Why Docker?When building a custom application it is sometimes necessary to include libraries and packages.If these dependencies become too burdensome, you may consider using Docker to avoid problems handing this application off from user to user.Thedocker-composetool adds additional functionality wherein you can define specific run-time configurations.What doesdipdo?Installing a CLI usingdip installis essentially syntactic sugar for:cd/path/to/docker-compose-dir
docker-composerun--rm<svc>$*You can accomplish the same thing with aliases, but this is a little more fun.ExampleConsider a trivial example of a Docker image with the AWS CLI installed.Writing aDockerfileWe will create aDockerfilethat installs this CLI and configures aVOLUMEfor mounting your AWS credentials:FROMalpineRUNapkadd--no-cachelessgroffpython3&&\pip3installawscliVOLUME/root/.awsENTRYPOINT["aws"]Writing adocker-compose.ymlOurdocker-compose.ymlwill define our service,dipex, and configure our AWS credentials (either throughENVvariables or the~/.awsdirectory):version: '3'
services:
  dipex:
    image: amancevice/dipex
    build: .
    environment:
      AWS_ACCESS_KEY_ID:
      AWS_SECRET_ACCESS_KEY:
    volumes:
      - ~/.aws:/root/.awsInstalling the CLIInstalling the CLI is as simple as:dipinstalldipex.Or, if you would like to install tracking a remote:dipinstalldipex.--remoteorigin/mainIf you are not currently inside the directory where yourdocker-compose.ymlfile is, supply it as a positional argument:dipinstalldipex/path/to/project[--remoteorigin/main]Using the CLI$dipexs3lss3://bkt/path/to/keyUninstall the CLIUninstalling the CLI simply removes the executable and can be done using theuninstallsubcommand:dipuninstalldipexExtended ConfigurationThe default configuration can be viewed using thedip configcommand:{"dipex":{"git":{"branch":"main","remote":"origin"},"home":"/path/to/project","name":"dipex","path":"/usr/local/bin"},}The defaultPATHfor installations can be changed by settingENVvariables:exportDIP_HOME=/path/to/settings.jsonexportDIP_PATH=/bath/to/binAfter an item is installed it will appear in thedipskey:$dipinstalldipex/path/to/project
$dipconfig{"dipex":{"home":"/path/to/project","name":"dipex","path":"/usr/local/bin"}}Use the--pathoption when installing/uninstalling to override the default path & use a custom one:$dipinstall--path/my/bindipex/path/to/project
$dipconfig{"dipex":{"home":"/path/to/project","name":"dipex","path":"/my/bin"}}Usedip config NAMEto display the configuration of an installed CLI:$dipconfigdipex{"home":"/path/to/project","name":"dipex","path":"/my/bin"}Usedip config NAME KEYto display a given configuration item$dipconfigdipexhome
/path/to/project# Handy trick...$cd$(dipconfigdipexhome)Usedip show NAMEto print the contents of thedocker-compose.ymlto screen:$dipshowdipex
version:'3'services:dipex:# ...