Docker Shortie, simplifying calls to CLI commands inside docker containers.

Overview

What is DockTie

Is a simple wrapper script for commands inside docker container(s).

So for instance, what you would normally run as:

     docker-compose exec node node --v

becomes

     node --version

after tool is configured and initialized.

How to Use

  1. Clone the code from same parent directory as your project.
~$ pwd
/my/work/projects/

~$ git clone https://github.com/docktie/docktie.git
  1. Configure

Assuming your project is named cooltool, create corresponding _env file

~$ pwd
/my/work/projects/
~$ cd docktie
~$ cp conf/env.sample conf/cooltool_env ## change the variables accordingly.

NOTE: check conf/env.sample. Depending on your site structure, you may need to define RELATIVE_DOCKERCOMPOSE_DIR.

  1. And initialize:
~$ pwd
/my/work/projects/cooltool
~$ ../docktie/init.sh
NOTE: DockTie Dev Helper initialized.
      Utils(/my/work/projects/docktie/utils) prioritized in $PATH

(docktie > cooltool) ~$

You will get a visual indicator like "(docktie > cooltool)" in your CLI prompt once you successfully initialized.

NOTE: It has to be run from within your project. Otherwise, you will see this error:

~$ pwd
/my/work/projects/docktie
~$ ./init.sh
ERROR: 'init.sh' must be called from within project directory.

When you're done

Simply run the exit command:

(docktie > cooltool) ~$ exit
exit
DockTie Dev Helper exited.

~$

Utils Customization

Utils Structure

The utils are inside "utils/bin" directory.

Notice that in majority of utils, only docktie_cli (utils/docktie_cli) is actually calling the core (lib/kernel/core.bash.inc). This is because, only the script name matters.

~$ nl -ba utils/bin/docktie_cli
     1  #!/bin/bash
     2
     3  ## -------- source common library ---------
     4  PROJECT_ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../ && pwd )"
     5  . $PROJECT_ROOTDIR/etc/controller.bash.inc
     6
     7
     8  ## list of functions to auto-load
     9  autoload_functions "kernel/core"
    10
    11  ## ..............................
    12  ## main utility tool starts below
    13  ## ..............................
    14  core $(basename $0) $*

In line 3 above,

$(basename $0)

is the script name which works for symbolic links too. This makes maintenance easier and can be automated later.

Now on the utils kernel side lib/kernel/core.bash.inc, except for docktie_cli, a corresponding config is also expected and sourced/included. So utils/bin/artisan MUST have a corresponding etc/docktie/utils/artisan.conf.

Utils Example

For a concrete example, say you want to add a psql util located on postgres container/service.

All you have to do is:

  1. Add the symlink
~$ pwd
/my/work/projects/docktie/utils/bin
~$ ln -s docktie_cli postgres
~$
  1. And the kernel config file etc/docktie/postgres.conf with below contents:
docker_service_name='postgres'
command_within_service="psql"

Test and enjoy!

Limitation

Your project must be described in docker-compose format. Pure Dockerfile is not supported yet.

Pull Requests

Send in Pull Request(s) if you have ideas or saw bugs. Thanks in advance :)

Credits

As tool grows, so does its dependency hell. It was thus refactored for easier maintenance and followed the SHCF-way.

Comments
  • Add relative custom location of docker-compose.yml per project

    Add relative custom location of docker-compose.yml per project

    Up to this point, it is always assumed to be inside project directory https://github.com/icasimpan/docktie/blob/master/init.sh#L34

    export DOCKTIE_DOCKER_COMPOSE_FULLPATH="$(pwd)/docker-compose.yml"
    

    the "$(pwd)" part as it equates to where the docktie is initialized and is a known fact that it's always enforced from within the project dir:

    ## Enforce calling "init.sh" from within project directory.
    ##
    DOCKTIE_DIR=$(dirname $0)
    if [[ "$DOCKTIE_DIR" != "../docktie" ]]; then
        echo "ERROR: 'init.sh' must be called from within project directory."
        exit 1
    else
        DOCKTIE_DIR="$(dirname $(pwd))/docktie"
    fi
    

    Sometimes, projects will be in separate subfolders so this has to be catered. This should be named: RELATIVE_DOCKERCOMPOSE_DIR That should be defined in each project's conf/*_env file

    enhancement PRIORITY_MEDIUM 
    opened by icasimpan 3
  • docktie_cli getx improvement: exempt from initializing docktie

    docktie_cli getx improvement: exempt from initializing docktie

    Currently, docktie needs to be initialized before running any docktie-related commands.

    ~/work/docktie$ ./utils/bin/docktie_cli getx backup_db
    ERROR: DockTie needs to be initialized.
    

    Check if there's a way to exempt just docktie_cli getx since it's helpful specially when initial project setup.

    This is what's blocking it at the moment but that's an initial assessment. Need to check further:

    ~$ grep -iR "ERROR: DockTie needs to be initialized." *
    utils/lib/kernel/core.bash.inc:         echo 'ERROR: DockTie needs to be initialized.'
    
    enhancement PRIORITY_MEDIUM 
    opened by casimpania 2
  • Create docktie_cli

    Create docktie_cli

    docktie_cli - envisioned as the only command a user needs to remember. It should help out in every possible tool usage.

    Initial subcommands idea:

    • help - all available commands. Default when no commands given.
    • list - lists all utilities (within utils)
    • shell <service_name> - ssh to service name
    • services - list all the docker services

    Do after #1 is done

    enhancement PRIORITY_HIGH 
    opened by casimpania 2
  • Add 'env' subcommand to docktie_cli

    Add 'env' subcommand to docktie_cli

    Idea is that it will show the exported environment variables that starts with DOCKTIE or PROJECT

    (docktie > cooltool) ~$ env|grep "^PROJECT\|^DOCKTIE"|sort
    

    where:

    • DOCKTIE - are for platform variables
    • PROJECT - except for $PROJECT_ROOTDIR, these are mostly defined in respective conf/*_env file.

    So, this would involve changes to init.sh as well to auto-detect all declared PROJECT_ (except for PROJECT_NAME). This is useful for things like shortcuts to BACKEND and FRONTEND or PARSER directories when working from command line.

    Parsing for env would be something like this:

    (docktie > cooltool) ~$ grep -v "^#\|^$\|^PROJECT_" env.sample
    DOCKER_CONTAINER_PREFIX=example
    AUTOSTART_PROJECT=0
    DOCKTIE_SERVICES_TO_START=""
    
    enhancement PRIORITY_LOW 
    opened by casimpania 1
  • Incorporate db backup mechanism

    Incorporate db backup mechanism

    See how it's done in https://ismael.casimpan.com/quicktasks/docker-mysql-backup-to-local/.

    NOTE: In a version of docker-compose (1.26.2 or is it all of version 1?), cp command is not available and thus needs to downgrade to using the native docker cp.

    enhancement PRIORITY_MEDIUM 
    opened by casimpania 1
  • Add visual indicator to PS1 about project name

    Add visual indicator to PS1 about project name

    Something like

    (docktie > cooltool) ~$
    

    Instead of just

    (docktie) ~$
    

    Relevant config to update is https://github.com/icasimpan/docktie/blob/master/conf/ps1_changer#L1

    Just add https://github.com/icasimpan/docktie/blob/master/conf/env.sample#L5 there.

    enhancement PRIORITY_MEDIUM 
    opened by icasimpan 1
  • Possible decoupling of services handled

    Possible decoupling of services handled

    See how practical it is to decouple services from utils/core. Idea is, user only has to provide a service config file and core will simply detect all that's inside the services config directory.

    Maybe, move utils/core into utils/kernel/core and services config into utils/kernel/config.

    enhancement PRIORITY_HIGH 
    opened by casimpania 1
  • Remove dash or underscore from project directory name when detecting parameter for init.sh

    Remove dash or underscore from project directory name when detecting parameter for init.sh

    Docker removes dashes or underscore from project folder name and use it as default prefix.

    Example, if your project is "cool_project-uat", container prefix becomes coolprojectuat.

    bug 
    opened by casimpania 0
  • Add option to allow running specific services during init

    Add option to allow running specific services during init

    When using some development environments like laradock, there are a lot of services that would be started if no specific ones are declared.

    Most of the time, you need only to run specific ones.

    enhancement 
    opened by casimpania 0
  • Allow docktie to auto-up the project when explicitly told to do so

    Allow docktie to auto-up the project when explicitly told to do so

    The reason docktie needs the project to be manually up is that it doesn't want to dictate it. Developer still has the higher control on when to start/stop/down the docker project.

    BUT once the docker-compose environment is fully configured ../docktie/init.sh COULD auto-up the project.

    To give developer the choice to enable it or not, add a flag to the conf/*_env file, something like: AUTOSTART_PROJECT=1 Should be zero or commented out by default.

    enhancement PRIORITY_MEDIUM 
    opened by icasimpan 0
  • Create 'alias' for all commands done by docktie

    Create 'alias' for all commands done by docktie

    In some instances, docktie is overkill (e.g. in customer environments) but alias is very very light and would be helpful.

    Idea is to think of docktie as the source code for aliases and "compiling" would mean creating those alias that can be run in any environment including local. It is also quite fast as compared to raw docktie commands.

    enhancement PRIORITY_LOW 
    opened by casimpania 0
  • Add feature for auto-switch user for certain containers defined in *_env file

    Add feature for auto-switch user for certain containers defined in *_env file

    Sometimes, there's a need to switch user as containers mostly use root by default.

    Define in _env and make sure the following are included:

    • container name
    • use to switch to
    • if there's a need to define shell (for those users defined with /sbin/nologin, e.g. 'www-data')
    enhancement PRIORITY_MEDIUM 
    opened by casimpania 0
  • docktie_cli getx: improv to allow bulk/grouped extension to get

    docktie_cli getx: improv to allow bulk/grouped extension to get

    Just like composer.lock where you have a lot of modules to install.

    Add it to something like a [getx] section of env file, one line per extension till a whitespace is found.

    This might help:

    • https://stackoverflow.com/questions/14676714/grep-match-all-characters-up-to-not-including-first-blank-space
    • https://stackoverflow.com/questions/7103531/how-to-get-the-part-of-a-file-after-the-first-line-that-matches-a-regular-expres
    enhancement PRIORITY_HIGH 
    opened by casimpania 1
  • devolve utils to docker-ext and only retain the core module (docktie_cli)

    devolve utils to docker-ext and only retain the core module (docktie_cli)

    CONS:

    • current symlinks to docktie_cli will now be a file (though still calling the docktie_cli way).

    PROS:

    • We can add an inline help at the top of each command
    • Developer may need to install a lot of extensions after but mitigated by #26

    NOTES:

    • Composer is still hardcoded within utils/lib/kernel/core.bash.inc. The rest are OK.
    enhancement PRIORITY_MEDIUM 
    opened by casimpania 0
Releases(v0.1.1)
  • v0.1.1(Mar 31, 2022)

    Nothing special, similar to v0.1.1-alpha except that this will be the last release before it moves to it's new home repo

    Full Changelog: https://github.com/icasimpan/docktie/compare/v0.1.1-alpha...v0.1.1

    Source code(tar.gz)
    Source code(zip)
  • v0.1.1-alpha(Mar 30, 2022)

    • Added docker-compose wrapper so it can be run anywhere while in docktie env
    • BugFix for relative docker-compose.yml. If you don't use that feature, there's no need to update to this release.

    Full Changelog: https://github.com/icasimpan/docktie/compare/v0.1.0-alpha...v0.1.1-alpha

    Source code(tar.gz)
    Source code(zip)
  • v0.0.2(Mar 30, 2022)

    • Added docker-compose wrapper so it can be run anywhere while in docktie env
    • BugFix for relative docker-compose.yml. If you don't use that feature, there's no need to update to this release.

    Full Changelog: https://github.com/icasimpan/docktie/compare/v0.0.1...v0.0.2

    Source code(tar.gz)
    Source code(zip)
  • v0.1.0-alpha(Mar 8, 2022)

    What's Changed

    • docktie_cli implementation - usable with minor quirks
    • utils refactor to escape dependency hell. Followed the shcf-way

    Full Changelog: https://github.com/icasimpan/docktie/commits/v0.1.0-alpha

    Previous Release

    v0.0.1 - initial implementation with acceptable behavior.

    No other release than this as next release (currently in Alpha v0.1.0-alpha) has a lot of major change that merits a higher release version.

    Source code(tar.gz)
    Source code(zip)
  • v0.0.1(Mar 8, 2022)

    What's Changed

    • Utils Kernel Decoupling by @casimpania in https://github.com/icasimpan/docktie/pull/3
    • Add project name to PS1 indicator by @casimpania in https://github.com/icasimpan/docktie/pull/7
    • Added License by @casimpania in https://github.com/icasimpan/docktie/pull/10
    • RELATIVE_DOCKERCOMPOSE_DIR added by @casimpania in https://github.com/icasimpan/docktie/pull/12

    Full Changelog: https://github.com/icasimpan/docktie/commits/v0.0.1

    Source code(tar.gz)
    Source code(zip)
Owner
null
Demo of how you can run your Laravel app with Docker Compose. Look at docker-compose.yml and the docker folder. The rest is just a clean Laravel + Horizon install.

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Matt 5 Oct 22, 2021
Quickly deploy a seedbox with self-hosted services and a web portal using Docker and docker-compose.

Seedbox Quickly deploy and configure a seedbox with self-hosted services and a web portal using Docker and a single docker-compose.yml file. Screensho

null 6 Dec 7, 2022
Finally a sane way to register available commands and arguments and match your command line in PHP

clue/commander Finally a sane way to register available commands and arguments and match your command line in PHP. You want to build a command line in

Christian Lück 172 Nov 27, 2022
Brew PHP switcher is a simple shell script to switch your apache and CLI quickly between major versions of PHP

Brew PHP switcher is a simple shell script to switch your apache and CLI quickly between major versions of PHP. If you support multiple products/projects that are built using either brand new or old legacy PHP functionality. For users of Homebrew (or brew for short) currently only.

Phil Cook 872 Dec 22, 2022
Full PHP development environment for Docker.

Full PHP development environment based on Docker. Use Docker First - Learn About It Later! Join Us Awesome People Laradock is an MIT-licensed open sou

laradock 11.7k Jan 7, 2023
A modern Docker LAMP stack and MEAN stack for local development

The Devilbox Usage | Architecture | Community | Features | Intranet | Screenshots | Contributing | Logos | License Support for valid https out of the

cytopia 4k Jan 8, 2023
Up and running with small Docker environments

Vessel Up and running with small Docker dev environments. Documentation Full documentation can be found at https://vessel.shippingdocker.com. Install

Shipping Docker 1.1k Dec 17, 2022
Symfony5 template w/ Docker config

Symfony5 w/ Docker config A project template in the following configuration: Symfony 5.2 PHP8 PostgreSQL 13.2 Separate Docker containers for Nginx, FP

Andrew Alyamovsky 5 May 14, 2022
Docker NAT容器自助部署php版本,实现从搭建到跑路的全生命周期功能。

DockerLabs-V1 游客可通过web页面直接创建出NAT容器,本项目从发布后将不再维护任何bug,以后有时间会出sdk重构版。 环境要求 使用了赛邮云发送短信号码,需要自己去申请appid和appkey填写到app_config.php文件中。需要修改所有html文件和api/kill.ph

xiz 35 Mar 4, 2022
The project provides a docker image for Files App(files.photo.gallery).

For the purpose of learning,I replace the files.js with cracked version which just remove authorization code.

cjy0526 30 Oct 16, 2022
Multipurpose VIP Docker container images

VIP Container Images This repository is used to build Docker container images used, among others, by the VIP Local Development Environment. Images are

Automattic 10 Nov 2, 2022
Laravel 5 with Dockerized Gulp, PHP-FPM, MySQL and nginx using docker-compose

docker-laravel Laravel 5 with Dockerized PHP-FPM, MySQL and nginx using docker-compose Usage Get Composer docker-compose run --rm phpnginx curl -O htt

Harsh Vakharia 83 Feb 8, 2022
Shopware 6 app boilerplate + Symfony backend + Dockware docker dev environment 💙

Shopware 6 app boilerplate with Symfony backend This boilerplate template can be used to get up and running with a docker-based dev setup for Shopware

Rune Laenen 8 Oct 11, 2022
Docker with PHP 7.4 fpm, Nginx, Composer, PhpUnit and MaridaDB

Clean Docker with PHP Docker with PHP 7.4 fpm, Nginx, Composer, PhpUnit and MariaDB Starting app docker-compose up -d Main page

Grzegorz Bielski 7 Nov 17, 2022
Ponto de partida para utilização do Docker Compose 💙✨

Docker-compose Docker | WSL2 | PHP | Nginx | MySQL Esse projeto fornece um ponto de partida para integrar diferentes serviços usando um arquivo Compos

Julia Tangerino 1 Nov 9, 2021
A package that allows you to generate simple and fast Docker configurations for your Laravel application!

A package that allows you to generate simple and fast Docker configurations for your Laravel application!

Lucas Nepomuceno 3 Oct 8, 2022
Docker-based workflow management system for Laravel

DevOption Workflows Workflows is a Docker-based workflow management system for Laravel applications. Installation You can install the package via comp

devoption.io 1 Jan 5, 2022
Runs a PHP-based startpage in Docker

docker-php-startpage Runs a PHP-based startpage in Docker Source code: GitHub Docker container: Docker Hub Image base: PHP Init system: N/A Applicatio

Logan Marchione 25 Dec 28, 2022
Lamp Docker skeleton PHP + Nginx + Mysql + Redis

Stop installing the entire development stack on your local machine. This project will allow you to quickly start working with php. To install, you need to install docker locally.

Krepysh 9 Dec 27, 2022