rkt: add basic main + build script

This commit is contained in:
Jonathan Boulle
2014-11-13 13:39:31 -08:00
parent ec56516bff
commit 78c67f76cf
3 changed files with 92 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
bin/
gopath/
Executable
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash -e
ORG_PATH="github.com/coreos-inc"
REPO_PATH="${ORG_PATH}/rkt"
if [ ! -h gopath/src/${REPO_PATH} ]; then
mkdir -p gopath/src/${ORG_PATH}
ln -s ../../../.. gopath/src/${REPO_PATH} || exit 255
fi
export GOBIN=${PWD}/bin
export GOPATH=${PWD}/gopath
eval $(go env)
echo "Building rkt..."
go build -o $GOBIN/rkt ${REPO_PATH}/rkt
+73
View File
@@ -0,0 +1,73 @@
package main
//
// Rocket is a reference implementation of the app container specification.
//
// Execution on Rocket is divided into a number of stages, and the `rkt`
// binary implements the first stage (stage 0), which consists of the
// following tasks:
// - Generating the Container Unique ID (UID)
// - Generating the container document
// - Creating a directory for the container
// - Copying the stage1 into the container directory
// - Copying the RAFs for each app into the stage2 directories
//
// Given a run command such as:
// rkt run --volume bind:/opt/tenant1/database \
// example.com/data-downloader-1.0.0 \
// example.com/ourapp-1.0.0 \
// example.com/logbackup-1.0.0
//
// the container doc generated will be compliant with the ACE spec.
//
import (
"flag"
"fmt"
"os"
"strings"
)
var (
fs = flag.NewFlagSet("rkt", flag.ExitOnError)
flagVolumes stringSlice
)
func init() {
fs.Var(&flagVolumes, "volume", "volumes to mount into the shared container environment")
}
func main() {
fs.Parse(os.Args[1:])
args := fs.Args()
if len(args) < 1 {
fmt.Fprintf(os.Stderr, "usage: rkt run [image...]\n")
os.Exit(0)
}
cmd := args[0]
switch cmd {
case "run":
default:
fmt.Fprintf(os.Stderr, "rkt: unknown subcommand: %q\n", cmd)
os.Exit(1)
}
fs.Parse(args[1:])
images := fs.Args()
fmt.Println("run rocket run")
fmt.Printf("images: %s\n", images)
fmt.Printf("volumes: %s\n", flagVolumes)
}
// stringSlice implements the flag.Value interface
type stringSlice []string
func (ss *stringSlice) Set(s string) error {
// TODO(jonboulle): validate
*ss = append(*ss, s)
return nil
}
func (ss *stringSlice) String() string {
return strings.Join(*ss, ",")
}