gockerfile

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

README

gockerfile

GolangCI

🐳 gockerfile is a YAML Docker-compatible alternative to the Dockerfile Specializing in simple go server.

Instalation as cmd

$ go get -u github.com/po3rin/gockerfile/cmd/gocker

Usage

po3rin/gocker config file

create Gockerfile.yaml (Gockerfile supports only 2 fields)

#syntax=po3rin/gocker

repo: github.com/po3rin/gockerfile
path: ./example/server

run go api server from repository source code. repo is git repository. path is path to main.go.

Build Gockerfile using docker build

you can use this in docker build

$ DOCKER_BUILDKIT=1 docker build -f Gockerfile.yaml .
Build with builtctl

gocker lets you build image from Gockerfile using buildctl & docker expoter.

$ gocker | buildctl build --exporter=docker --exporter-opt name=gockersample | docker load

or using as buildkit frontend.

buildctl build \
		--frontend=gateway.v0 \
		--frontend-opt=source=po3rin/gocker \
		--local dockerfile=. \
		--local context=. \
		--exporter=docker \
		--exporter-opt name=gockersample | docker load

Run container

you can exec go api container.

$ docker run -it -p 8080:8080 po3rin/gockersample:latest /bin/server
$ curl localhost:8080/
Hello World

Documentation

Index

Constants

View Source
const (
	LocalNameContext    = "context"
	LocalNameDockerfile = "dockerfile"
)

Variables

This section is empty.

Functions

func Build

func Build(ctx context.Context, c client.Client) (*client.Result, error)

func GetGockerfileConfig

func GetGockerfileConfig(ctx context.Context, c client.Client) (*config.Config, error)

Types

type HealthConfig

type HealthConfig struct {
	// Test is the test to perform to check that the container is healthy.
	// An empty slice means to inherit the default.
	// The options are:
	// {} : inherit healthcheck
	// {"NONE"} : disable healthcheck
	// {"CMD", args...} : exec arguments directly
	// {"CMD-SHELL", command} : run command with system's default shell
	Test []string `json:",omitempty"`

	// Zero means to inherit. Durations are expressed as integer nanoseconds.
	Interval    time.Duration `json:",omitempty"` // Interval is the time to wait between checks.
	Timeout     time.Duration `json:",omitempty"` // Timeout is the time to wait before considering the check to have hung.
	StartPeriod time.Duration `json:",omitempty"` // The start period for the container to initialize before the retries starts to count down.

	// Retries is the number of consecutive failures needed to consider a container as unhealthy.
	// Zero means inherit.
	Retries int `json:",omitempty"`
}

HealthConfig holds configuration settings for the HEALTHCHECK feature.

type Image

type Image struct {
	specs.Image

	// Config defines the execution parameters which should be used as a base when running a container using the image.
	Config ImageConfig `json:"config,omitempty"`
}

func Gocker2LLB

func Gocker2LLB(c *config.Config) (llb.State, *Image, error)

Gocker2LLB converts gockerfile yml to LLB.

func NewImageConfig

func NewImageConfig(c *config.Config) *Image

type ImageConfig

type ImageConfig struct {
	specs.ImageConfig

	Healthcheck *HealthConfig `json:",omitempty"` // Healthcheck describes how to check the container is healthy
	ArgsEscaped bool          `json:",omitempty"` // True if command is already escaped (Windows specific)

	//	NetworkDisabled bool                `json:",omitempty"` // Is network disabled
	//	MacAddress      string              `json:",omitempty"` // Mac Address of the container
	OnBuild     []string          // ONBUILD metadata that were defined on the image Dockerfile
	StopTimeout *int              `json:",omitempty"` // Timeout (in seconds) to stop a container
	Shell       strslice.StrSlice `json:",omitempty"` // Shell for shell-form of RUN, CMD, ENTRYPOINT
}

ImageConfig is a docker compatible config for an image

Directories

Path Synopsis
cmd
example
gin

Jump to

Keyboard shortcuts

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