Code Monkey home page Code Monkey logo

dcompose's Introduction

Dcompose

Latest Stable Version Latest Unstable Version Build Status License Total Downloads

Introduction

Laradock is an awesome tool that helps with building a Docker environment for running your Laravel or PHP apps.

However, it can be quite a pain to identify and use only specific components needed for your app. Most of the time you'll find yourself using only few images and remembering which one (So you can run docker-compose up -d ..) for which project is a pain.

I built Dcompose because I was always finding myself copying the images' Docker files needed from laradock to my projects and recreating the docker-compose.yml file everytime for each project. Inspired by Composer, I embarked on a quest to build my own tool that would "require" in my projects only the components that I needed and update automatically my docker-compose.yml file.

This is how Dcompose was born. I do not know where this library will end up but my hope is for people who've had the same issue as me might find it useful.

License

Dcompose is open-sourced software licensed under the MIT license

Installation

Fisrt make sur you have Docker and Docker Compose installed on your system. Check out Docker and Docker Compose installation docs.

Then, download Dcompose using Composer:

$ composer global require percymamedy/dcompose

Make sure to place composer's system-wide vendor bin directory in your $PATH so the Dcompose executable can be located by your system. This directory exists in different locations based on your operating system; however, some common locations include:

  • macOS: $HOME/.composer/vendor/bin
  • GNU / Linux Distributions: $HOME/.config/composer/vendor/bin

Usage

Init command

With the init command you may start defining which services you want to use in your project. You should run this command in the root of your project like follows:

$ dcompose init

This is an interacting command which will ask you about your project name and services which you'll use. Services are just the Laradock services which exists, check out laradock's github repo to get a sense of all services which you can require.

After running this command a new .docker/ folder will be created into your project's root directory which will contain only the services and correct docker-compose.yml file layout.

You will also find a .env file inside the .docker folder. You can modify this file to change values specific for your environment.

Now you may run the following command inside the .docker/ folder to run your project :

$ docker-compose up -d

Require command

If you've missed a service or you need another service from laradock you can run the require command as follows:

$ dcompose require <service_name>

Where <service_name> is the name of one of laradock's services. This will then add the service to your .docker/ folder and docker-compose.yml file.

Now you may run the following command inside the .docker/ folder :

$ docker-compose up -d

or :

$ ./containers start

If you've ran the generate-tools command.

Remove command

You can remove a service using the following command :

$ dcompose remove <service_name>

This is not going to remove the service folder from the .docker/ folder and correct sections from docker-compose.yml file.

However the container, image and volume created for this service will still be on your system. To remove them completely you should run docker commands :

$ docker rm <container_name>
$ docker rmi <image_name>
$ docker volume rm <volume_name>

Generate tools command

Generating the commands line tools helps in running and executing docker containers from laradock :

$ dcompose generate-tools

A new containers script will be created which gives you access to three options:

Start docker containers:

$ ./containers start

Stop docker containers:

$ ./containers stop

Ssh into workspace container after starting contaners :

$ ./containers workspace

Refresh command

laradock files are fetched and cached such that require, remove and init command are carried out faster without the need to refetch files from dist all the time.

However, there is not way of knowing when laradock has been updated, thus the refresh command allows us to refresh the cached laradock files :

$ dcompose refresh

Road map v0.2

  • Make code more consistent with an object oriented approach.
  • Use something like doctrine cache for managing laradock file hence eliminating the need for refresh command by having expiration.

Road map v0.3

  • Add a manifest file in JSON or YML that will contain all docker containers hence eliminating the need for commiting the .docker folder.

Credits

Big Thanks to all developers who worked hard to create something amazing!

Creator

Percy Mamedy

Twitter: @PercyMamedy
GitHub: percymamedy

dcompose's People

Contributors

percymamedy avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

dcompose's Issues

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.