diff --git a/api/structs.go b/api/structs.go index e7ef3c7..4912275 100644 --- a/api/structs.go +++ b/api/structs.go @@ -15,7 +15,6 @@ type Source struct { type Recipe struct { Name string Id string - Cwd string Stages []Stage Path string ParentPath string diff --git a/core/build.go b/core/build.go index 5c2c808..0c73d45 100644 --- a/core/build.go +++ b/core/build.go @@ -85,11 +85,10 @@ func BuildContainerfile(recipe *api.Recipe) error { if len(stage.Copy) > 0 { for _, copy := range stage.Copy { if len(copy.Paths) > 0 { - if copy.Workdir != "" && copy.Workdir != recipe.Cwd { + if copy.Workdir != "" { _, err = containerfile.WriteString( fmt.Sprintf("WORKDIR %s\n", copy.Workdir), ) - recipe.Cwd = copy.Workdir if err != nil { return err } @@ -148,11 +147,10 @@ func BuildContainerfile(recipe *api.Recipe) error { // RUN(S) if !stage.SingleLayer { if len(stage.Runs.Commands) > 0 { - if stage.Runs.Workdir != "" && stage.Runs.Workdir != recipe.Cwd { + if stage.Runs.Workdir != "" { _, err = containerfile.WriteString( fmt.Sprintf("WORKDIR %s\n", stage.Runs.Workdir), ) - recipe.Cwd = stage.Runs.Workdir if err != nil { return err } @@ -182,11 +180,10 @@ func BuildContainerfile(recipe *api.Recipe) error { if len(stage.Adds) > 0 { for _, add := range stage.Adds { if len(add.SrcDst) > 0 { - if add.Workdir != "" && add.Workdir != recipe.Cwd { + if add.Workdir != "" { _, err = containerfile.WriteString( fmt.Sprintf("WORKDIR %s\n", add.Workdir), ) - recipe.Cwd = add.Workdir if err != nil { return err } @@ -222,11 +219,10 @@ func BuildContainerfile(recipe *api.Recipe) error { continue } - if cmd.Workdir != "" && cmd.Workdir != recipe.Cwd { + if cmd.Workdir != "" { _, err = containerfile.WriteString( fmt.Sprintf("WORKDIR %s\n", cmd.Workdir), ) - recipe.Cwd = cmd.Workdir if err != nil { return err } @@ -244,11 +240,10 @@ func BuildContainerfile(recipe *api.Recipe) error { // SINGLE LAYER if stage.SingleLayer { if len(stage.Runs.Commands) > 0 { - if stage.Runs.Workdir != "" && stage.Runs.Workdir != recipe.Cwd { + if stage.Runs.Workdir != "" { _, err = containerfile.WriteString( fmt.Sprintf("WORKDIR %s\n", stage.Runs.Workdir), ) - recipe.Cwd = stage.Runs.Workdir if err != nil { return err } @@ -287,11 +282,10 @@ func BuildContainerfile(recipe *api.Recipe) error { } // CMD - if stage.Cmd.Workdir != "" && stage.Cmd.Workdir != recipe.Cwd { + if stage.Cmd.Workdir != "" { _, err = containerfile.WriteString( fmt.Sprintf("WORKDIR %s\n", stage.Cmd.Workdir), ) - recipe.Cwd = stage.Cmd.Workdir if err != nil { return err } @@ -306,11 +300,10 @@ func BuildContainerfile(recipe *api.Recipe) error { } // ENTRYPOINT - if stage.Entrypoint.Workdir != "" && stage.Entrypoint.Workdir != recipe.Cwd { + if stage.Entrypoint.Workdir != "" { _, err = containerfile.WriteString( fmt.Sprintf("WORKDIR %s\n", stage.Entrypoint.Workdir), ) - recipe.Cwd = stage.Entrypoint.Workdir if err != nil { return err } diff --git a/core/loader.go b/core/loader.go index 6d50da7..fdd822b 100644 --- a/core/loader.go +++ b/core/loader.go @@ -19,7 +19,7 @@ import ( // Does not validate the recipe but it will catch some errors // a proper validation will be done in the future func LoadRecipe(path string) (*api.Recipe, error) { - recipe := &api.Recipe{Cwd: "/"} + recipe := &api.Recipe{} // we use the absolute path to the recipe file as the // root path for the recipe and all its files @@ -94,7 +94,7 @@ func LoadRecipe(path string) (*api.Recipe, error) { // the includes directory is the place where we store all the // files to be included in the container, this is useful for // example to include configuration files. Each file must follow - // the File Hierachy Standard (FHS) and be placed in the correct + // the File Hierarchy Standard (FHS) and be placed in the correct // directory. For example, if you want to include a file in // /etc/nginx/nginx.conf you must place it in includes/etc/nginx/nginx.conf // so it will be copied to the correct location in the container