sti

package
v0.0.0-...-d87d6f2 Latest Latest
Warning

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

Go to latest
Published: May 1, 2014 License: Apache-2.0 Imports: 15 Imported by: 0

README

go-sti

This is the golang implementation of the source-to-images tool.

Getting started
Dependencies
  1. Docker
  2. Go
Installation
go get github.com/openshift/docker-source-to-images/go
Example

You can start using sti right away with the following test sources and publicly available images:

sti build git://github.com/pmorie/simple-ruby pmorie/centos-ruby2 test-ruby-app
docker run -rm -i -p :9292 -t test-ruby-app

sti build git://github.com/pmorie/simple-ruby pmorie/ubuntu-buildpack test-foreman-app \
-e 'BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-ruby.git'
docker run -rm -i -p :5000 -t test-foreman-app

sti build git://github.com/pmorie/simple-html pmorie/fedora-mock test-html-app
docker run -rm -i -p :8080 -t sti_app
Validating a source image
sti validate BUILD_IMAGE_TAG [flags]

Available Flags:
     --debug=false: Enable debugging output
 -I, --incremental=false: Validate for an incremental build
 -R, --runtime="": Set the runtime image to use
 -U, --url="unix:///var/run/docker.sock": Set the url of the docker socket to use

You can validate that an image is usable as a sti source image as follows:

sti validate BUILD_IMAGE_TAG

The --incremental option to enables validation for incremental builds:

sti validate BUILD_IMAGE_TAG --incremental
Building a deployable image with sti
sti build SOURCE BUILD_IMAGE APP_IMAGE_TAG [flags]

Available Flags:
     --clean=false: Perform a clean build
     --debug=false: Enable debugging output
     --dir="tempdir": Directory where generated Dockerfiles and other support scripts are created
 -e, --env="": Specify an environment var NAME=VALUE,NAME2=VALUE2,...
 -R, --runtime="": Set the runtime image to use
 -U, --url="unix:///var/run/docker.sock": Set the url of the docker socket to use

The most basic sti build uses a single build image:

sti build SOURCE BUILD_IMAGE_TAG APP_IMAGE_TAG

If the build is successful, the built image will be tagged with APP_IMAGE_TAG.

If the build image is compatible with incremental builds, sti build will look for an image tagged with APP_IMAGE_TAG. If an image is present with that tag, sti build will save the build artifacts from that image and add them to the build container at /tmp/artifacts so an image's /usr/bin/prepare script can restore them before building the source.

When using an image that supports incremental builds, you can do a clean build with --clean:

sti build SOURCE BUILD_IMAGE_TAG APP_IMAGE_TAG --clean

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileExistsInContainer

func FileExistsInContainer(dockerClient *docker.Client, cId string, path string) bool

Determine whether a file exists in a container.

Types

type BuildRequest

type BuildRequest struct {
	Request
	Source      string
	Ref         string
	Tag         string
	Clean       bool
	Environment map[string]string
	Method      string
	Writer      io.Writer
}

type BuildResult

type BuildResult STIResult

func Build

func Build(req BuildRequest) (*BuildResult, error)

Build processes a BuildRequest and returns a *BuildResult and an error. An error represents a failure performing the build rather than a failure of the build itself. Callers should check the Success field of the result to determine whether a build succeeded or not.

type Request

type Request struct {
	BaseImage string

	DockerSocket  string
	DockerTimeout int
	WorkingDir    string
	Debug         bool
}

Request contains essential fields for any request: a Configuration, a base image, and an optional runtime image.

type STIResult

type STIResult struct {
	Success  bool
	Messages []string
}

type StiError

type StiError int
const (
	ErrDockerConnectionFailed StiError = iota
	ErrNoSuchBaseImage
	ErrNoSuchRuntimeImage
	ErrPullImageFailed
	ErrSaveArtifactsFailed
	ErrCreateDockerfileFailed
	ErrCreateContainerFailed
	ErrInvalidBuildMethod
	ErrBuildFailed
	ErrCommitContainerFailed
	ErrInvalidRef
)

func (StiError) Error

func (s StiError) Error() string

type ValidateRequest

type ValidateRequest struct {
	Request
	Incremental bool
}

Describes a request to validate an images for use in an sti build.

type ValidateResult

type ValidateResult STIResult

func Validate

func Validate(req ValidateRequest) (*ValidateResult, error)

Service the supplied ValidateRequest and return a ValidateResult.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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