docker

package
v0.0.0-...-56a2066 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: BSD-3-Clause Imports: 15 Imported by: 2

Documentation

Overview

Package docker is for running Dockerfiles.

Index

Constants

This section is empty.

Variables

View Source
var (
	AUTH_SCOPES = []string{auth.ScopeUserinfoEmail, auth.ScopeFullControl}

	REPOSITORY_HOST = "gcr.io"
)

Functions

func Build

func Build(ctx context.Context, args ...string) error

Build runs "docker build <args>" in 'directory' and streams the output. The log output is parsed into sub-steps for each line starting with "Step N/M : ACTION value"

Examples:

Step 1/7 : FROM debian:testing-slim
---> e205e0c9e7f5
Step 2/7 : RUN apt-get update && apt-get upgrade -y && apt-get install -y   git   python    curl
---> Using cache
---> 5b8240d40b63

OR

Step 2/7 : RUN apt-get update && apt-get upgrade -y && apt-get install -y   git   python    curl
---> Running in 9402d36e7474
Step 3/7 : RUN mkdir -p --mode=0777 /workspace/__cache
Step 5/7 : ENV CIPD_CACHE_DIR /workspace/__cache
Step 6/7 : USER skia

func BuildHelper

func BuildHelper(ctx context.Context, directory, tag, configDir string, buildArgs map[string]string) error

Build a Dockerfile.

There must be a Dockerfile in the 'directory' and the resulting output is tagged with 'tag'.

func BuildPushImageFromInfraImage

func BuildPushImageFromInfraImage(ctx context.Context, appName, image, tag, repo, configDir, workDir, infraImageTag string, topic *pubsub.Topic, cmd, volumes, env []string, buildArgs map[string]string) error

BuildPushImageFromInfraImage is a utility function that pulls the infra image, runs the specified buildCmd on the infra image, builds the specified image+tag, pushes it. After pushing it sends a pubsub msg signaling completion.

func Login

func Login(ctx context.Context, accessToken, hostname, configDir string) error

Login to docker to be able to run authenticated commands (Eg: docker.Push).

func PublishToTopic

func PublishToTopic(ctx context.Context, image, tag, repo string, topic *pubsub.Topic) error

PublishToTopic publishes a message to the pubsub topic which is subscribed to by https://github.com/google/skia-buildbot/blob/cd593cf6c534ba7a1bd2d88a488d37840663230d/docker_pushes_watcher/go/docker_pushes_watcher/main.go#L335 The tag will be used to determine if the image should be updated.

func Pull

func Pull(ctx context.Context, imageWithTag, configDir string) error

Pull a Docker image.

func Push

func Push(ctx context.Context, tag, configDir string) (string, error)

Push a Docker image.

func Run

func Run(ctx context.Context, image, configDir string, cmd, volumes, env []string) error

Run does a "docker run".

volumes should be in the form of "ARG1:ARG2" where ARG1 is the local directory and ARG2 will be the directory in the image. Note the above does a --rm i.e. it automatically removes the container when it exits.

func Tag

func Tag(ctx context.Context, imageID, tag, configDir string) error

Tag the given Docker image.

Types

type Docker

type Docker struct {
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, ts oauth2.TokenSource) (*Docker, error)

func (*Docker) Build

func (d *Docker) Build(ctx context.Context, args ...string) error

Run "docker build" with the given args.

func (*Docker) Cleanup

func (d *Docker) Cleanup(ctx context.Context) error

func (*Docker) Extract

func (d *Docker) Extract(ctx context.Context, image, src, dest string) error

Extract the given src from the given image to the given host dest.

func (*Docker) Pull

func (d *Docker) Pull(ctx context.Context, imageWithTag string) error

Pull a Docker image.

func (*Docker) Push

func (d *Docker) Push(ctx context.Context, tag string) (string, error)

Push a Docker file.

func (*Docker) Run

func (d *Docker) Run(ctx context.Context, image string, cmd, volumes, env []string) error

Run does a "docker run".

volumes should be in the form of "ARG1:ARG2" where ARG1 is the local directory and ARG2 will be the directory in the image. Note the above does a --rm i.e. it automatically removes the container when it exits.

func (*Docker) Tag

func (d *Docker) Tag(ctx context.Context, imageID, tag string) error

Tag the given Docker image.

Jump to

Keyboard shortcuts

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