Code Monkey home page Code Monkey logo

stitchocker's Introduction

Stitchocker

License Release GitHub file size in bytes GitHub top language

๐ŸŒˆ Stitchoker its a lightweight and fast command line utility utility for conveniently grouping your docker-compose multiple container services as a single application.

Installation

The easiest way to install the latest binaries for Linux and Mac is to run this in a shell:

via curl

sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/alexaandrov/stitchocker/master/install.sh)"

via wget

sudo bash -c "$(wget -O- https://raw.githubusercontent.com/alexaandrov/stitchocker/master/install.sh)"

Manual installation

If you dont like to curl | bash you can download release from here:

https://github.com/alexaandrov/stitchocker/releases

Or via git clone https://github.com/alexaandrov/stitchocker.git

And then install script manually:

Option 1

sudo cp /path-to-release/stitchocker.sh /usr/local/bin/stitchocker
sudo chmod +x /usr/local/bin/stitchocker

Option 2

chmod +x /path-to-release/stitchocker.sh

In your .bashrc

alias stitchocker="/path-to-release/stitchocker.sh"

Usage

First create in your services parent directory `docker-compose.yml' file.

This config file should be looks like:

sets:
    # Default set running by default
    default:
        # You can refer to the services that are in the directory with the stithocker config (parent directory)

        parent-service-name
        
        # You can also point to relative sub directories
        
        folder-in-parent/another-folder/parent-service-name

        # You can refer to the exported paths in your shell config (eg ~/.bashrc).
        # In your shell config in this case should be:
        # export SERVICES="/absolute-path-to-services-dir"

        @services/service-name-in-services-alias
        
        # You can also specify the absolute path to the directory with the service docker compose config
        
        ~/you-services-dir/another-directory/service-name
        /home/user/you-services-dir/another-directory/service-name

        # You can import your custom sets

        @custom

    custom:
        another-parent-service-name
        @services/another-service-name-in-services-alias
        
# Use this if you want to forward an environment from your env config to each service
# Once you have created the env file in stitchocker directory and specified the path in stitchocker config 
# You can use environment in your service like this:
# "YOUR_SERVICE_ENV_NAME=${ENV_NAME_FROM_YOUR_PROJECT_FILE}" in service docker compose environment field
# Also you can test services environment via command "stitchocker config" in your stitchocker project
# Read more about environment here: https://docs.docker.com/compose/environment-variables/

env: parent-path-to-env-file

Then run in your shell:

stitchocker up

Also you can run stitchocker in debug mode:

stitchocker --debug up

Or in verbose mode:

stitchocker --verbose up

Stitchocker help message

$ stitchocker -h

Usage:
        stitchocker [--verbose|--debug] [-a <env_alias>] [docker-compose COMMAND] [SETS...]
        stitchocker -h|--help
        stitchocker -v|--version


Options:
        -h|--help            Shows this help text
        -v|--version         Shows stitchocker version
        --update             Updates stitchocker to the latest stable version
        --debug              Runs all commands in debug mode
        --verbose            Runs all commands in verbose mode
        -p                   Path to stitching directory
        -a                   Alias to stitching directory

Examples:
        stitchocker up
        stitchocker up default backend frontend
        stitchocker -a my-projects-alias-from-env up default backend frontend
        stitchocker --debug -a my-projects-alias-from-env up default backend frontend
        stitchocker --verbose -a my-projects-alias-from-env up default backend frontend

Usage Example

~ $ cat ~/.bashrc
export SERVICES="~/services"
~ $ cd ~/services
~/services $ tree .
โ”œโ”€โ”€ reverse-proxy
    โ””โ”€โ”€ ...
    โ””โ”€โ”€ docker-compose.yml
โ”œโ”€โ”€ mysql
    โ””โ”€โ”€ ...
    โ””โ”€โ”€ docker-compose.yml
โ”œโ”€โ”€ redis
    โ””โ”€โ”€ ...
    โ””โ”€โ”€ docker-compose.yml
~ $ cd ~/projects/demo-project
~/projects/demo-project $ tree .
โ”œโ”€โ”€ docker-compose.yml
โ”œโ”€โ”€ platform
    โ””โ”€โ”€ ...
    โ””โ”€โ”€ docker-compose.yml
โ”œโ”€โ”€ landing
    โ””โ”€โ”€ ...
    โ””โ”€โ”€ docker-compose.yml
โ”œโ”€โ”€ storybook
    โ””โ”€โ”€ ...
    โ””โ”€โ”€ docker-compose.yml
~/projects/demo-project $ cat docker-compose.yml
sets:
    default:
        - @services
        - platform
        - frontend-services/landing
        - @development

    services:
        - @services/reverse-proxy
        - /home/demo-user/services/mysql
        - ~/services/mysql
    
    development:
        - storybook
~/projects/demo-project $ stitchocker up
Starting reverse-proxy_proxy_1 ... done
Starting mysql_mysql_1 ... done
Starting redis_redis_1 ... done
Starting platform_platform_1 ... done
Starting landing_landing_1 ... done
Starting storybook_storybook_1 ... done

or

~/projects/demo-project $ stitchocker stop
Stoping reverse-proxy_proxy_1 ... done
Stoping mysql_mysql_1 ... done
Stoping redis_redis_1 ... done
Stoping platform_platform_1 ... done
Stoping landing_landing_1 ... done
Stoping storybook_storybook_1 ... done

or

~/projects/demo-project $ stitchocker up services
Starting reverse-proxy_proxy_1 ... done
Starting mysql_mysql_1 ... done
Starting redis_redis_1 ... done

or

~/projects/demo-project $ stitchocker up services devolpment
Starting reverse-proxy_proxy_1 ... done
Starting mysql_mysql_1 ... done
Starting redis_redis_1 ... done
Starting storybook_storybook_1 ... done

And so on :)

Configuration

Custom stitchocker config name

By default stitchocker can handle:

  • stitchocker.yml
  • stitchocker.yaml
  • docker-compose.yml
  • docker-compose.yaml

You can change it:

export STITCHOCKER_CONFIG=your-custom-config-name

Custom stitchocker default set name

By default the set name is default

You can change it:

export STITCHOCKER_DEFAULT_SET=your-default-set-name

Copyright and license

Code released under the Apache 2.0 license. See LICENSE for the full license text.

stitchocker's People

Contributors

alexaandrov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

stitchocker's Issues

Intriguing but it doesn't work at all?

Tried the simple example given,

$ ./stitchocker.sh up
yaml: line 3: found character that cannot start any token

Seems to be complaining about the @ symbol.

I put @services into a quote, then I get:

(root) Additional property sets is not allowed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.