Skip to content
Permalink
Browse files
feat(staged-dockerfile): complete instructions set with all params in…
… the dockerfile parser pkg

Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
  • Loading branch information
distorhead committed Oct 12, 2022
1 parent 9500967 commit 06f122b06a47552c822c64c0345e3551cbe07e0c
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 21 deletions.
@@ -83,7 +83,7 @@ func mapDockerfileToImagesSets(ctx context.Context, cfg *dockerfile.Dockerfile,
return nil, fmt.Errorf("unable to create image %q: %w", "test", err)
}

img.stages = append(img.stages, stage_instruction.NewRun(backend_instruction.NewRun(*dockerfile_instruction.NewRun([]string{"ls", "/"})), nil, false, &stage.BaseStageOptions{
img.stages = append(img.stages, stage_instruction.NewRun(backend_instruction.NewRun(*dockerfile_instruction.NewRun([]string{"ls", "/"}, nil, nil, false)), nil, false, &stage.BaseStageOptions{
ImageName: img.Name,
ImageTmpDir: img.TmpDir,
ContainerWerfDir: img.ContainerWerfDir,
@@ -1,12 +1,14 @@
package instruction

type Add struct {
Src []string
Dst string
Src []string
Dst string
Chown string
Chmod string
}

func NewAdd(src []string, dst string) *Add {
return &Add{Src: src, Dst: dst}
func NewAdd(src []string, dst, chown, chmod string) *Add {
return &Add{Src: src, Dst: dst, Chown: chown, Chmod: chmod}
}

func (i *Add) Name() string {
@@ -0,0 +1,15 @@
package instruction

import "github.com/moby/buildkit/frontend/dockerfile/instructions"

type Arg struct {
Args []instructions.KeyValuePairOptional
}

func NewArg(args []instructions.KeyValuePairOptional) *Arg {
return &Arg{Args: args}
}

func (i *Arg) Name() string {
return "ARG"
}
@@ -1,11 +1,12 @@
package instruction

type Cmd struct {
Cmd []string
Cmd []string
PrependShell bool
}

func NewCmd(cmd []string) *Cmd {
return &Cmd{Cmd: cmd}
func NewCmd(cmd []string, prependShell bool) *Cmd {
return &Cmd{Cmd: cmd, PrependShell: prependShell}
}

func (i *Cmd) Name() string {
@@ -1,13 +1,15 @@
package instruction

type Copy struct {
From string
Src []string
Dst string
From string
Src []string
Dst string
Chown string
Chmod string
}

func NewCopy(from string, src []string, dst string) *Copy {
return &Copy{From: from, Src: src, Dst: dst}
func NewCopy(from string, src []string, dst, chown, chmod string) *Copy {
return &Copy{From: from, Src: src, Dst: dst, Chown: chown, Chmod: chmod}
}

func (i *Copy) Name() string {
@@ -1,11 +1,12 @@
package instruction

type Entrypoint struct {
Entrypoint []string
Entrypoint []string
PrependShell bool
}

func NewEntrypoint(entrypoint []string) *Entrypoint {
return &Entrypoint{Entrypoint: entrypoint}
func NewEntrypoint(entrypoint []string, prependShell bool) *Entrypoint {
return &Entrypoint{Entrypoint: entrypoint, PrependShell: prependShell}
}

func (i *Entrypoint) Name() string {
@@ -1,8 +1,10 @@
package instruction

import "github.com/docker/docker/api/types/container"

type Healthcheck struct {
Type HealthcheckType
Command string
Type HealthcheckType
Config *container.HealthConfig
}

type HealthcheckType string
@@ -12,3 +14,11 @@ var (
HealthcheckTypeCmd HealthcheckType = "CMD"
HealthcheckTypeCmdShell HealthcheckType = "CMD-SHELL"
)

func NewHealthcheck(t HealthcheckType, cfg *container.HealthConfig) *Healthcheck {
return &Healthcheck{Type: t, Config: cfg}
}

func (i *Healthcheck) Name() string {
return "HEALTHCHECK"
}
@@ -0,0 +1,9 @@
package instruction

type Maintainer struct {
Maintainer string
}

func (i *Maintainer) Name() string {
return "MAINTAINER"
}
@@ -1,11 +1,16 @@
package instruction

import "github.com/opencontainers/runtime-spec/specs-go"

type Run struct {
Command []string
Command []string
Args []string // runtime args like --security and --network
Mounts []specs.Mount // structured --mount args
PrependShell bool
}

func NewRun(command []string) *Run {
return &Run{Command: command}
func NewRun(command, args []string, mounts []specs.Mount, prependShell bool) *Run {
return &Run{Command: command, Args: args, Mounts: mounts, PrependShell: prependShell}
}

func (i *Run) Name() string {

0 comments on commit 06f122b

Please sign in to comment.