Giter Club home page Giter Club logo

dev-box's Introduction

DevBox

A Vagrant + Docker + CLI setup for a development box

Ever wanted to have just one Vagrant machine to work across multiple projects? Well, now you can!

Usage

git clone this repository to $HOME/somewhere in order to create the path as following: $HOME/somewhere/dev-box. Put the dev-box/cli/dev-box.py into your $PATH. In my local setup, I created a symbolic link to the dev-box.py and made it available in my $PATH. From now on I'm assuming you created a symbolic link to $HOME/somewhere/dev-box/cli/dev-box.py, named it devbox and made it available in your $PATH.

Then, setup the Vagrant machine. It will take a time, but it shouldn't take a lot.

$ devbox setup

If everything went well (and if it didn't, please post a bug ๐Ÿž in issues), you should be able to hook any directory to the Vagrant machine through the command below:

$ devbox hook .

In this case, . is the current working directory (CWD) (echo $PWD); it's the current directory where the devbox command was called. It will basically create a link between the current directory with the Vagrant's VM /hook folder. Thus, you will be able to run any command from within the Vagrant machine using the files and folders listed in .. It is only possible to hook one folder at a time. The CWD will be available in Vagrant's VM /hook path. You may hook absolute or relative paths as well. Once the hook is done, you may run commands from within the /hook folder:

$ devbox console

or

$ devbox run [commands]

or

$ devbox stream [commands]

The first command opens a /bin/zsh shell prompt at the Vagrant's $HOME folder; the second one runs the [commands] as it would be written directly in the shell, from $HOME (arguments and options are proxied to the machine through the vagrant ssh -c command); the last one will stream/run commands from the /hook folder.

To release a hook, just run:

$ devbox unhook

For any other option, please run devbox -h.

Dockering

Docker is available by default; you don't have to hook any folder in order to run a container โ€” if the image is available. If you run $ devbox run docker [commands] you can build images or create containers as it would be available in the host machine (well, likely, the only difference is the use of an IP address different to 127.0.0.1|0.0.0.0|localhost; in this case defaulted to 192.168.44.88 โ€” you may change that in dev-box/Vagrantfile or creating a dev-box/Vagrantfile.local configuring any additional option to the Vagrant machine, including its IP address).

Tip

Create an alias for the docker installation inside this virtual machine:

alias docker="devbox run docker"

Now you can use the docker command normally, as it would be called from the host machine.

Well, what about docker-machine?

Yes, I know, docker-machine provides (almost) the same services and it also has a larger community to keep it really good. But I also need to take control over the Vagrant/VirtualBox machine. I use it not only for "dockering".

Assumptions & Limitations

This CLI tool and its configurations assume that Vagrant's virtual machine provider is VirtualBox. Also, it uses the VBoxManager to create transient shared folders and to enable them to create symbolic links. The VirtualBox's User Manual states that "[f]or security reasons the guest OS is not allowed to create symlinks by default. If you trust the guest OS to not abuse the functionality, you can enable creation of symlinks (...)" Thus, it is important to notice this warning โ€” and to not abuse that functionality, for your own safety.

Support & Contributing

If you have found any bug ๐Ÿž or don't know how to do something or ever wanted a new feature, please create an issue in /issues. Thank you!

License

MIT License ยฉ Ewerton Assis

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.