Git Product home page Git Product logo

docker-clone's Introduction

Docker Clone

Developing with micro-services is awesome, but it can be a little boring sometimes. Having to setup everything, make the services talking together, databases properly set, etc.

Happily, Docker comes into play, and completely deals with all your painful processes. It abstracts everything you need, setup databases for you, creates a common network, and connect every services together. It’s a huge gain. But this brings a problem: how should you organize your repos? Should you do a mono-repo? Multi-repos? And if you do multi-repos, how are you supposed to clone all of your GitHub or GitLab repos without having to open every repo, find its URL, clone the directory into your workspace, …?

Come Docker Clone!

Opinions

Docker Clone is opinionated. It expects from you that you’re working with micro-services, and with multi-repos. Multi-repos are better. They’re much more isolated, it forces to decouple by design, it ensures no one can access databases from other services, and they’re much more easily manageable for one person or a team. You’re just concerned by your repos, and nothing else. Just grab the interfaces of other services, and work on your business logic. That’s all.

Docker Clone has been created due to the work on French Pastries. It is made to respond to needs of micro-services, mainly made with JavaScript (and JavaScript’s family) and Node.

How does it work?

Docker Clone uses a file named docker-clone.yml to get which repos should be cloned, how they should be named, and where they should resides. Usually, it is placed at the root of a directory, as well as a docker-compose.yml file to run everything once it’s downloaded.

In correct order, Docker Clone:

  1. Fetch the docker-clone.yml file.
  2. Determine the correct working directory in which repo-cloning should happen.
  3. Iterate over all the repos, and trigger a git clone in the working directory.
  4. Name the repos accordingly to the docker-clone.yml file.

What is the file format?

The Docker Clone config file is a YAML file, to be coherent with Docker. It is somewhat similar to a docker-compose.yml, because it only describes what should be done. The default config file is named docker-clone.yml. It is made of an optional working_dir field at root (initialized at ../ if not set), and a repos field, containing an array of repo object. A repo is made of two fields: an url field, and a name field. The first one should be either an HTTPS or a git address, for git to clone the repo, and a name corresponding to the repo name.

Example of docker-clone.yml

working_dir: '../' # ../ is the default value for working_dir if not set.
repos:
  - url: [email protected]:ghivert/my-awesome-docker-server.git
    name: docker-server
  - url: https://gitlab.com/wolfoxco/my-second-awesome-server.git
    name: other-docker-server

Installation

You can use the gem utility to install Docker Clone.

gem install docker-clone

You now have the docker-clone command globally installed.

Usage

Docker Clone is easy to use. Just type docker-clone without any argument, and it will launch, search for docker-clone.yml, and install everything.

You can use -h or --help to display help directly. The other option is -c, or --config, followed by a path to the config file. It will be used instead of docker-clone.yml.

You can also use a programmatic access. Add the docker-clone gem to your Gemfile, run a bundle install, and you can require "docker-clone" directly into your Ruby files. It gives access to a DockerClone object.

The object must be initialized with an options map, with working_dir and config_file_path. Then, run clone_repos and it will install everything.

require "docker_clone"

# Folder structure
# workspace
# └── docker-cloner
#     ├── .git/
#     ├── .gitignore
#     ├── docker-clone.yml
#     ├── docker-compose.yml
#     └── README.md

# Initialize the object. It reads the config file during initialization.
cloner = DockerClone.new(
  working_dir: '../',
  # working_dir will be expanded to the workspace directory.
  config_file_path: './docker-clone.yml'
  # config_file_path will be expanded to docker-clone.yml in the root directory.
)
# And clone the repos!
clone.clone_repos

Contributions

Do you love the package? Love the utility? Want to improve it? PR are welcome, as well as issues!

docker-clone's People

Contributors

ghivert avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.