Skip to content

Commit

Permalink
feat(staged-dockerfile): all dockerfile options and instructions /1
Browse files Browse the repository at this point in the history
Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
  • Loading branch information
ilya-lesikov committed Oct 26, 2022
1 parent b14b793 commit f0cde50
Show file tree
Hide file tree
Showing 20 changed files with 696 additions and 119 deletions.
2 changes: 1 addition & 1 deletion cmd/buildah-test/main.go
Expand Up @@ -47,7 +47,7 @@ echo STOP
defer os.RemoveAll("/tmp/build_stage.sh")

if err := b.RunCommand(ctx, "mycontainer", []string{"/.werf/build_stage.sh"}, buildah.RunCommandOpts{
Mounts: []specs.Mount{
LegacyMounts: []specs.Mount{
{
Type: "bind",
Source: "/tmp/build_stage.sh",
Expand Down
2 changes: 2 additions & 0 deletions pkg/build/image/dockerfile.go
Expand Up @@ -129,6 +129,8 @@ func mapDockerfileToImagesSets(ctx context.Context, cfg *dockerfile.Dockerfile,

var stg stage.Interface
switch typedInstr := any(instr).(type) {
case *dockerfile.DockerfileStageInstruction[*dockerfile_instruction.Arg]:
// TODO: implement
case *dockerfile.DockerfileStageInstruction[*dockerfile_instruction.Add]:
stg = stage_instruction.NewAdd(stageName, typedInstr, dockerfileImageConfig.Dependencies, !isFirstStage, baseStageOptions)
case *dockerfile.DockerfileStageInstruction[*dockerfile_instruction.Cmd]:
Expand Down
56 changes: 39 additions & 17 deletions pkg/buildah/common.go
Expand Up @@ -10,9 +10,11 @@ import (
"runtime"
"strings"

"github.com/moby/buildkit/frontend/dockerfile/instructions"
"github.com/opencontainers/runtime-spec/specs-go"

"github.com/werf/werf/pkg/buildah/thirdparty"
"github.com/werf/werf/pkg/dockerfile/instruction"
"github.com/werf/werf/pkg/util"
"github.com/werf/werf/pkg/werf"
)
Expand Down Expand Up @@ -44,6 +46,7 @@ type BuildFromCommandsOpts struct {

type BuildFromDockerfileOpts struct {
CommonOpts

ContextDir string
BuildArgs map[string]string
Target string
Expand All @@ -58,46 +61,65 @@ type RunMount struct {

type RunCommandOpts struct {
CommonOpts
WorkingDir string
User string
Args []string
Mounts []specs.Mount

ContextDir string
PrependShell bool
Shell []string
AddCapabilities []string
DropCapabilities []string
NetworkType instruction.NetworkType
WorkingDir string
User string
Envs []string
Mounts []instructions.Mount
LegacyMounts []specs.Mount // TODO(ilya-lesikov): migrate to Mounts
}

type RmiOpts struct {
CommonOpts

Force bool
}

type CommitOpts struct {
CommonOpts

Image string
}

type ConfigOpts struct {
CommonOpts
Labels []string
Volumes []string
Expose []string
Envs map[string]string
Cmd []string
Entrypoint []string
User string
Workdir string
Healthcheck string
OnBuild string
StopSignal string
Shell []string

Labels []string
Volumes []string
Expose []string
Envs map[string]string
Cmd []string
CmdPrependShell bool
Entrypoint []string
EntrypointPrependShell bool
User string
Workdir string
Healthcheck *thirdparty.HealthConfig
OnBuild string
StopSignal string
Shell []string
Maintainer string
}

type CopyOpts struct {
CommonOpts
From string

Chown string
Chmod string
}

type AddOpts struct {
CommonOpts

ContextDir string
Chown string
Chmod string
}

type (
Expand Down

0 comments on commit f0cde50

Please sign in to comment.