Coder Social home page Coder Social logo

rkd's Introduction

rkd

Think Dockerfile & docker-compose for rkt containers

up

rkd (aka rock-it dev) is a simple tool to build and run rkt containers locally.

$ rkd
Development environments powered by rkt containers, with ease.

Usage:
  rkd [command]

Available Commands:
  build       Build the containers
  help        Help about any command
  up          Run the container
  version     Print the version number of rkd

Flags:
  -h, --help   help for rkd

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

$ sudo rkd up
/root/.rkd/5290facf0b502d01ba15b7de9a1b9633.aci already built
/root/.rkd/a023872855269062eca818f2ea8c0b32.aci already built
rkt --insecure-options=image --net=host run --interactive --volume src,kind=host,source=/home/odino/projects/go/src/github.com/odino/rkd/example/src /root/.rkd/a023872855269062eca818f2ea8c0b32.aci
[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node index.js`
server started...

Usage

Suppose you have a NodeJS webserver running locally with docker-compose and want to convert it to rkt, without using conversion tool like docker2aci & the likes.

First, create your prod.rkd which is basically docker's Dockerfile:

set-name example.com/node-hello
dep add quay.io/coreos/alpine-sh
run -- apk add --update nodejs
copy src /src
set-working-directory /src
set-exec -- node index.js
port add www tcp 8080

and create a dev.rkd which is your new docker-compose.yml, where you can define commands dependencies you only need on your local machine:

run -- npm install -g nodemon
mount add src src
set-exec -- nodemon index.js

That's it, now run rkd up in the current folder:

sudo rkd up   
Building /root/.rkd/prod-5290facf0b502d01ba15b7de9a1b9633.aci
acbuild begin
acbuild set-name example.com/node-hello
acbuild dep add quay.io/coreos/alpine-sh
acbuild run -- apk add --update nodejs
Downloading quay.io/coreos/alpine-sh: [========================] 2.65 MB/2.65 MB
fetch http://dl-4.alpinelinux.org/alpine/v3.2/main/x86_64/APKINDEX.tar.gz
(1/4) Installing libgcc (4.9.2-r6)
(2/4) Installing libstdc++ (4.9.2-r6)
(3/4) Installing libuv (1.5.0-r0)
(4/4) Installing nodejs (0.12.10-r0)
Executing busybox-1.23.2-r0.trigger
OK: 28 MiB in 19 packages
acbuild copy src /src
acbuild set-working-directory /src
acbuild set-exec -- node index.js
acbuild port add www tcp 8080
acbuild write /root/.rkd/prod-5290facf0b502d01ba15b7de9a1b9633.aci
acbuild end
Building /root/.rkd/dev-a023872855269062eca818f2ea8c0b32.aci
acbuild begin ./prod.aci
acbuild run -- npm install -g nodemon
Downloading quay.io/coreos/alpine-sh: [========================] 2.65 MB/2.65 MB
npm WARN optional dep failed, continuing [email protected]
/usr/bin/nodemon -> /usr/lib/node_modules/nodemon/bin/nodemon.js
[email protected] /usr/lib/node_modules/nodemon
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
acbuild mount add src src
acbuild set-exec -- nodemon index.js
acbuild write /root/.rkd/dev-a023872855269062eca818f2ea8c0b32.aci
acbuild end
rkt --insecure-options=image --net=host run --interactive --volume src,kind=host,source=/home/odino/projects/go/src/github.com/odino/rkd/example/src /root/.rkd/dev-a023872855269062eca818f2ea8c0b32.aci
[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node index.js`
server started...

and you can head to localhost:8080.

Installation

Make sure acbuild is installed in your system.

Builds for a few systems are available in the releases.

Alternatively, you can compile it straight away:

git clone [email protected]:odino/rkd.git
cd rkd

go build -o rkd main.go
mv rkd /usr/local/bin

and then you have the rkd executable up & running.

Why this?

One of the arguments against rkt is that building and running containers seems generally more complicated than using docker, so I decided to figure out a way to replicate docker's simplicity on dev environments -- 2 files, one command, running app.

The *.rkd files are basically a list or acbuild instructions used for building 2 ACIs (prod.aci & dev.aci): rkd scans them, building the ACIs, and bases dev.aci off of what it build in prod.aci.

Troubleshooting

There's a plethora of stuff that could / needs to be done here as this is an early stage weekend project. There's very less error handling etc in the codebase and that's something I wish to work on granted that (1) I can find the time and (2) there's some interest here.

rkd's People

Contributors

odino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

tedj rob-pw

rkd's Issues

No such file or directory ./prod.aci

acbuild([]string{"begin", "./prod.aci"})

I believe this line is causing error:

rkd up
/root/.rkd/prod-bf3b63b754b857fb21ee5e6502e7a753.aci already built
Building /root/.rkd/dev-b61fc978a0187de3455b6667537a047c.aci
acbuild begin ./prod.aci
begin: no such file or directory: ./prod.aci
acbuild end
end: no build in progress in this working dir - try "acbuild begin"
panic: exit status 1 [recovered]
	panic: exit status 1

goroutine 1 [running]:
github.com/odino/rkd/utils.Execute(0xc42000ca00, 0x2, 0x2, 0x6616a0, 0xc42000e010, 0x6616e0, 0xc42000e018, 0x6616e0, 0xc42000e020)
	/home/odino/projects/go/src/github.com/odino/rkd/utils/utils.go:66 +0x159
github.com/odino/rkd/cmd.acbuild(0xc4200498c8, 0x1, 0x1)
	/home/odino/projects/go/src/github.com/odino/rkd/cmd/build.go:35 +0x309
github.com/odino/rkd/cmd.buildAci.func2()
	/home/odino/projects/go/src/github.com/odino/rkd/cmd/build.go:65 +0x77
panic(0x593d20, 0xc42000c9e0)
	/usr/lib/go-1.8/src/runtime/panic.go:489 +0x2cf
github.com/odino/rkd/utils.Execute(0xc42001ab40, 0x3, 0x3, 0x6616a0, 0xc42000e010, 0x6616e0, 0xc42000e018, 0x6616e0, 0xc42000e020)
	/home/odino/projects/go/src/github.com/odino/rkd/utils/utils.go:66 +0x159
github.com/odino/rkd/cmd.acbuild(0xc420049c00, 0x2, 0x2)
	/home/odino/projects/go/src/github.com/odino/rkd/cmd/build.go:35 +0x309
github.com/odino/rkd/cmd.buildAci(0x5a1fd0, 0x3)
	/home/odino/projects/go/src/github.com/odino/rkd/cmd/build.go:86 +0x375
github.com/odino/rkd/cmd.glob..func1(0x678460, 0x695050, 0x0, 0x0)
	/home/odino/projects/go/src/github.com/odino/rkd/cmd/build.go:23 +0x54
github.com/odino/rkd/cmd.glob..func2(0x678460, 0x695050, 0x0, 0x0)
	/home/odino/projects/go/src/github.com/odino/rkd/cmd/up.go:19 +0x57
github.com/spf13/cobra.(*Command).execute(0x678460, 0x695050, 0x0, 0x0, 0x678460, 0x695050)
	/home/odino/projects/go/src/github.com/spf13/cobra/command.go:660 +0x23a
github.com/spf13/cobra.(*Command).ExecuteC(0x678240, 0x5a1ff1, 0x3, 0x0)
	/home/odino/projects/go/src/github.com/spf13/cobra/command.go:735 +0x339
github.com/spf13/cobra.(*Command).Execute(0x678240, 0x0, 0x0)
	/home/odino/projects/go/src/github.com/spf13/cobra/command.go:694 +0x2b
main.main()
	/home/odino/projects/go/src/github.com/odino/rkd/main.go:12 +0x31

Forced net=host

Currently, for the sake of demoing, containers use --net=host by default. This should be behind a flag.

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.