func (s *parsingState) addToCurrStage(d Directive) error {
	stage, err := s.currStage()
	if err != nil {
		return err
	}
	stage.addDirective(d)
	return nil
}
Add this command to the build stage.
package dockerfile
type Stage struct {
	From       *FromDirective
	Directives []Directive
}
type Stages []*Stage
func newStage(from *FromDirective) *Stage {
	return &Stage{from, make([]Directive, 0)}
}
func (s *Stage) addDirective(d Directive) {
	s.Directives = append(s.Directives, d)
}
type parsingState struct {
	stages []*Stage
	passedArgs map[string]string
	globalArgs map[string]string
	stageVars map[string]string
}
func newParsingState(vars map[string]string) *parsingState {
	return &parsingState{
		make([]*Stage, 0), vars, make(map[string]string), nil,
	}
}
func (s *parsingState) currStage() (*Stage, error) {
	if len(s.stages) == 0 {
		return nil, errBeforeFirstFrom
	}
	return s.stages[len(s.stages)-1], nil
}
func (s *parsingState) addStage(stage *Stage) {
	s.stages = append(s.stages, stage)
}