dockbox

command module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

README ΒΆ

Group 1 (2)

build status License

dockbox is a useful CLI tool for trying out code from remote repositories. It allows you to to try out code quickly and easily without compromising your own system, and easily organize your workspace. Plus, it makes it very easy to delete the dependencies and other side effects that result from running the code.

All you need is Docker installed on your system, and let dockbox do the rest.

πŸš€ Getting Started

dockbox currently requires Docker to run. Please visit https://docs.docker.com/get-started/ for installation instructions.

Installing from Precompiled Binaries

Install the latest release for your OS/architecture. If the binary is in a non-standard location, please remember to update your PATH variable accordingly.

Installing with homebrew

If you have homebrew installed on your system:

  1. brew tap sriharivishnu/dockbox https://github.com/dockboxhq/cli
  2. brew install dockbox
Installing from Source

If installing dockbox from the source, clone the repository and run go install in the root directory to install dockbox on your system.


After installing dockbox, run dockbox create <url> to create a dockbox from a URL. The code repository that you choose does not need to have a Dockerfile to run, but if it does, dockbox will use it to create a dockbox. Otherwise, it will generate one for you.

Once you are done with the dockbox, clean up your resources with dockbox clean <dockbox name> which will clean up all side-effects/resources associated with the code you just installed. The dockbox name is usually the repository name that you cloned from, but if you want to be sure, you can use dockbox list to list out all the dockboxes installed on your system.

To summarize, there are 5 easy steps to getting started:

  1. Install dockbox
  2. dockbox create <url>
  3. dockbox clean <dockbox name>

For a full list of available commands, dockbox help

⭐ Features

-> % dockbox help

Usage: dockbox [OPTIONS] COMMAND

Manage workspaces and dependencies with ease in an isolated, secure environment.

To get started with dockbox, try entering:

        dockbox create <url>

Usage:
  dockbox [command]

Available Commands:
  clean       Removes a dockbox from your machine
  create      Creates a dockbox from a URL, file or git URL
  enter       Enters into a dockbox in a given directory
  help        Help about any command
  list        List all your dockboxes on your system
  tree        Shows a tree of dockbox image histories

Flags:
      --config string   config file (default is $HOME/.dockbox.yaml)
  -h, --help            help for dockbox

Use "dockbox [command] --help" for more information about a command.

Clean up

Easily clean up relevant images and side effects with the dockbox clean command

Screen Shot 2021-07-17 at 3 12 39 AM

πŸ“˜ Algorithm

Generate Dockerfile Algorithm

Currently, the algorithm for generating a Dockerfile is simple. We walk the file tree of the project, counting the number of files associated with each programming language. Then, we ask user which language should we generate a Dockerfile for, given the most frequent files found in the project.

In the future, dockbox will compose a tree in which we can store more information about modules, and resolve multi-module projects better.

Clean Up Algorithm

Internally, dockbox constructs a forest of images in order to construct a deletion plan for the images installed on a user's system. This is to avoid both dependent child images errors, and also associated container errors. To construct such a forest, we take each image given by Docker's List images, and run a history command using the image IDs. This approach is faster than using the Image Inspect API call (which only returns the parent image) since history only needs to be called on each of the leaf images.

Screen Shot 2021-07-17 at 3 12 39 AM

Here is the description of the algorithm for deleting a node from the forest:

Algorithm:
1. Find image ID of target Node
2. a) If target node has children, then for each child:

         i) Skip the child if it has already been previously visited
         
         ii) Perform a postorder search on the tree rooted at that child, adding entries to the deletion queue. 
             If any tagged images that are leaves were visited, confirm with user before adding the entries to the deletion queue. 
         
   b) Else
        i) if image is tagged, then confirm user with before adding to deletion queue
        ii) Else, add to deletion queue immediately
        
3. a) If the user has aborted the search by responding no to deletion of node, or if we have reached a node in which the parent is null, 
      then we are done.  
   b) Otherwise, we visit the parent node and perform steps 2-3 again.

4. Delete the images in the deletion queue. 

dockbox uses the following data structures to aid in executing the algorithm efficiently:

  • map from Image ID to ImageNode
  • queue of Image IDs to represent deletion plan
  • each node in the forest has both a parent pointer, and an array of children

✈️ Roadmap

This project is still a work in progress! We will continue to add more features as we explore more use cases. If you have ideas on possible additions of features you would like to see added to dockbox, reach out at srihari.vishnu@gmail.com, or better yet, open a pull request!

Features in Progress:

  • Allowing URLs other than git repositories
  • Adding better customizability for images and commands
  • Multi-module support to analyze a file tree and give possible groupings of a possible project structure
    • This is useful when say having a backend and a frontend in different folders in the same repository
  • Add ability to define custom rules for Dockerfile generation

πŸ§‘β€πŸ€β€πŸ§‘ Contributing

There is still a lot of work to do on this project! All help is welcome!

To get started contributing, please ensure that go and docker installed are installed on your system. After, run the following steps to build a binary and run it:

  1. cd dockbox
  2. go build -v ./...
  3. dockbox help

The repository follows the standard structure of a Cobra Go CLI project. For questions and inquiries, again feel free to reach out at srihari.vishnu@gmail.com.

If there are no open issues to work on, here are some ideas on how you can contribute:

  • Add documentation
  • Create tests
  • Add more options to commands to give more granular control
  • Implement features for Roadmap

To run tests, run go test -v in the cmd directory. To update the golden files, run go test -update.

License

This project is licensed under the Apache 2.0 License.

Documentation ΒΆ

Overview ΒΆ

Copyright Β© 2021 Srihari Vishnu srihari.vishnu@gmail.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Directories ΒΆ

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL