dockerpatch

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2017 License: MIT Imports: 6 Imported by: 0

README

dockerpatch

🐳 Read, write, manipulate, convert & apply filters to Dockerfiles

GoDoc

Web demo

A demo is available on dockerpatch.appspot.com

Screenshot

Install

go get github.com/moul/dockerpatch/...

Examples

$ cat input
FROM ubuntu:14.04

RUN apt-get update && apt-get install wget -y
RUN wget http://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb
RUN dpkg -i influxdb_latest_amd64.deb
RUN rm -r /opt/influxdb/shared

VOLUME /opt/influxdb/shared

CMD /usr/bin/influxdb --pidfile /var/run/influxdb.pid -config /opt/influxdb/shared/config.toml

EXPOSE 8083
EXPOSE 8086
EXPOSE 8090
EXPOSE 8099

$ dockerpatch --to-arm --optimize ./input
FROM armbuild/ubuntu:14.04
RUN apt-get update && apt-get install wget -y && wget http://s3.amazonaws.com/influxdb/influxdb_latest_armhf.deb && dpkg -i influxdb_latest_armhf.deb && rm -r /opt/influxdb/shared
VOLUME /opt/influxdb/shared
CMD /usr/bin/influxdb --pidfile /var/run/influxdb.pid -config /opt/influxdb/shared/config.toml
EXPOSE 8083 8086 8090 8099

cat input | dockerpatch --to-arm -
FROM armbuild/ubuntu:14.04
RUN apt-get update && apt-get install wget -y
RUN wget http://s3.amazonaws.com/influxdb/influxdb_latest_armhf.deb
RUN dpkg -i influxdb_latest_armhf.deb
RUN rm -r /opt/influxdb/shared
VOLUME /opt/influxdb/shared
CMD /usr/bin/influxdb --pidfile /var/run/influxdb.pid -config /opt/influxdb/shared/config.toml
EXPOSE 8083
EXPOSE 8086
EXPOSE 8090
EXPOSE 8099

cat input | dockerpatch --disable-network -
FROM ubuntu:14.04
RUN apt-get update && apt-get install wget -y
RUN wget http://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb
RUN dpkg -i influxdb_latest_amd64.deb
RUN rm -r /opt/influxdb/shared
VOLUME /opt/influxdb/shared
CMD /usr/bin/influxdb --pidfile /var/run/influxdb.pid -config /opt/influxdb/shared/config.toml

Usage

$ dockerpatch -h
NAME:
   dockerpatch - Read, write, manipulate, convert & apply filters to Dockerfiles

USAGE:
   dockerpatch [global options] command [command options] [arguments...]

VERSION:
   0.1.0

AUTHOR(S):
   Manfred Touron <https://github.com/moul/dockerpatch>

COMMANDS:
   patch	Patch a Dockerfile with filters
   help, h	Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h		show help
   --version, -v	print the version
$ dockerpatch patch -h
NAME:
   patch - Patch a Dockerfile with filters

USAGE:
   command patch [command options] [arguments...]

DESCRIPTION:
   patch [--to-arm]

OPTIONS:
   --to-arm		Convert to armhf architecture
   --disable-network	Remove network rules
   --optimize		Optimize Dockerfile

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NodeGetArgs

func NodeGetArgs(node *parser.Node) []string

NodeGetArgs returns the arguments of a node

func NodeGetLine

func NodeGetLine(node *parser.Node) string

NodeGetLine returns the arguments of a node as a string

func ParseLine

func ParseLine(line string) (*parser.Node, error)

ParseLine returns an AST node based on a line

Types

type Dockerfile

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

func DockerfileFromString

func DockerfileFromString(input string) (*Dockerfile, error)

DockerfileFromString reads a Dockerfiler as string

func DockerfileNew

func DockerfileNew() *Dockerfile

DockerfileNew returns an empty Dockerfile

func DockerfileRead

func DockerfileRead(input io.Reader) (*Dockerfile, error)

DockerfileRead reads a Dockerfile as io.Reader

func (*Dockerfile) AddLineAfterFrom

func (d *Dockerfile) AddLineAfterFrom(line string) error

AddLineAfterFrom parses and add a line after from in the AST

func (*Dockerfile) AddNodeAfterFrom

func (d *Dockerfile) AddNodeAfterFrom(node *parser.Node) error

AddNodeAfterFrom adds a node after from in the AST

func (*Dockerfile) AppendLine

func (d *Dockerfile) AppendLine(line string) error

AppendLine parses and appends a new line to the AST

func (*Dockerfile) AppendNode

func (d *Dockerfile) AppendNode(node *parser.Node) error

AppendNode attach a new node on last position of the AST

func (*Dockerfile) FilterDisableNetwork

func (d *Dockerfile) FilterDisableNetwork() error

func (*Dockerfile) FilterOptimize

func (d *Dockerfile) FilterOptimize() error

func (*Dockerfile) FilterToArm

func (d *Dockerfile) FilterToArm(destArchitecture string) error

func (*Dockerfile) From

func (d *Dockerfile) From() string

GetFrom returns the current FROM

func (*Dockerfile) GetNodesByType

func (d *Dockerfile) GetNodesByType(nodeType string) []*parser.Node

GetNodesByType returns nodes matching a type

func (*Dockerfile) Length

func (d *Dockerfile) Length() int

Length returns length of the AST

func (*Dockerfile) PrependLine

func (d *Dockerfile) PrependLine(line string) error

PrependLine parses and prepends a new line to the AST

func (*Dockerfile) PrependNode

func (d *Dockerfile) PrependNode(node *parser.Node) error

PrependNode attach a new node on first position of the AST

func (*Dockerfile) RemoveAt

func (d *Dockerfile) RemoveAt(i int) error

func (*Dockerfile) RemoveNodesByType

func (d *Dockerfile) RemoveNodesByType(nodeType string) error

RemoveNodesByType removes all nodes of a specific type from the AST

func (*Dockerfile) Replace

func (d *Dockerfile) Replace(from, to string) error

Replace tries to replace a string with another in each lines

func (*Dockerfile) SetFrom

func (d *Dockerfile) SetFrom(from string) error

SetFrom sets the current FROM

func (*Dockerfile) String

func (d *Dockerfile) String() string

String returns a docker-readable Dockerfile

Directories

Path Synopsis
cmd
dockerpatch command

Jump to

Keyboard shortcuts

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