Giter Site home page Giter Site logo

udhos / conbox Goto Github PK

View Code? Open in Web Editor NEW
37.0 7.0 3.0 63 KB

conbox is a Go implementation of unix-like utilities as single static executable intended for small container images.

License: MIT License

Go 98.10% Shell 0.43% Dockerfile 1.47%
go golang busybox containers unix-like shell

conbox's Introduction

license Go Report Card

conbox

conbox is a Go implementation of unix-like utilities as single static executable intended for small container images.

Created by gh-md-toc

Install

git clone https://github.com/udhos/conbox ;# clone outside of GOPATH
cd conbox
GO111MODULE=on go install ./conbox

Usage

Available applets

List available applets:

$ conbox
conbox: version 0.0 runtime go1.12.4 GOMAXPROC=1 OS=linux ARCH=amd64

usage: conbox APPLET [ARG]... : run APPLET
       conbox -h              : show command-line help
       conbox -l              : list applets

conbox: registered applets:
cat echo ls mkdir printenv pwd rm rmdir shell which

See all implemented applets here:

https://github.com/udhos/conbox/tree/master/applets

Basename usage

You can create a symbolic link for a supported applet pointing to 'conbox':

ln -s ~/go/bin/conbox ~/bin/cat
~/bin/cat /etc/passwd

Subcommand usage

Pass applet name as subcommand to 'conbox':

conbox cat /etc/passwd

Shell usage

All applets are also directly available from within conbox shell:

$ conbox shell
conbox: version 0.0 runtime go1.12.4 GOMAXPROC=1 OS=linux ARCH=amd64

welcome to conbox shell.
this tiny shell is very limited in features.
however you can run external programs normally.
some hints:
       - use 'conbox' to see all applets available as shell commands.
       - use 'help' to list shell built-in commands.
       - 'exit' terminates the shell.

shell built-in commands:
builtin cd exit help

conbox shell$

Adding new applet

  1. Create a new package for the applet under directory 'applets'. The package must export the function Run() as show in example below.
$ more applets/myapp/run.go
package myapp // put applet myapp in package myapp

import (
        "fmt"

        "github.com/udhos/conbox/common"
)

// Run executes the applet.
func Run(tab map[string]common.AppletFunc, args []string) int {

        fmt.Println("myapp: hello")

        return 0 // exit status
}
  1. In file 'conbox/applets.go', import the applet package and include its Run() function in the applet table:
$ more conbox/applets.go
package main

import (
	// (...)
        "github.com/udhos/conbox/applets/myapp" // <-- import the applet package
	// (...)
)

func loadApplets() map[string]common.AppletFunc {
        tab := map[string]common.AppletFunc{
		// (...)
                "myapp": myapp.Run, // <-- point applet name to its Run() function
		// (...)
        }
        return tab
}
  1. Rebuild conbox and test the new applet:
$ go install ./conbox
$ conbox myapp
myapp: hello

Docker

Get 'conbox' as docker image udhos/conbox:latest from:

https://hub.docker.com/r/udhos/conbox

Run in docker

Run applet:

docker run --rm udhos/conbox:latest cat /etc/passwd

Run interactive shell:

docker run --rm -ti udhos/conbox:latest shell

Docker recipes

Build docker image:

./docker/build.sh

Tag image:

docker tag udhos/conbox udhos/conbox:latest

Push image:

docker login
docker push udhos/conbox:latest

Related work

Go Projects

Unfortunately these projects seem inactive:

Non-Go projects

conbox's People

Contributors

udhos 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

conbox's Issues

Project Goals?

Whilst you have listed similar projects as being inactive (true from my own analysis) what are your stated project goals here? Do you intend to incorporate those projects here (they do implement some applets you don't have), Do you intend to go further? What is the intended use of conbox? As a direct replacement for busybox?

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.