diff --git a/config/config.go b/config/config.go index 72351c87f..6df5579f3 100644 --- a/config/config.go +++ b/config/config.go @@ -161,13 +161,14 @@ type Checksum struct { // Docker image config type Docker struct { - Binary string `yaml:",omitempty"` - Goos string `yaml:",omitempty"` - Goarch string `yaml:",omitempty"` - Goarm string `yaml:",omitempty"` - Image string `yaml:",omitempty"` - Dockerfile string `yaml:",omitempty"` - Latest bool `yaml:",omitempty"` + Binary string `yaml:",omitempty"` + Goos string `yaml:",omitempty"` + Goarch string `yaml:",omitempty"` + Goarm string `yaml:",omitempty"` + Image string `yaml:",omitempty"` + Dockerfile string `yaml:",omitempty"` + Latest bool `yaml:",omitempty"` + Files []string `yaml:"extra_files,omitempty"` // Capture all undefined fields and should be empty after loading XXX map[string]interface{} `yaml:",inline"` diff --git a/docs/130-docker.md b/docs/130-docker.md index 65e5f4550..0f5ee3db8 100644 --- a/docs/130-docker.md +++ b/docs/130-docker.md @@ -52,6 +52,10 @@ dockers: dockerfile: Dockerfile # Also tag and push myuser/myimage:latest latest: true + # If your dockerfile copies more files other than the binary itself, + # you should list them here as well. + extra_files: + - config.yml ``` These settings should allow you to generate multiple docker images, using diff --git a/pipeline/docker/docker.go b/pipeline/docker/docker.go index b6bb9e011..84cc1b4d9 100644 --- a/pipeline/docker/docker.go +++ b/pipeline/docker/docker.go @@ -71,6 +71,11 @@ func process(ctx *context.Context, folder string, docker config.Docker, binary c if err := os.Link(docker.Dockerfile, dockerfile); err != nil { return errors.Wrap(err, "failed to link dockerfile") } + for _, file := range docker.Files { + if err := os.Link(file, filepath.Join(root, filepath.Base(file))); err != nil { + return errors.Wrapf(err, "failed to link extra file '%s'", file) + } + } if err := dockerBuild(root, dockerfile, image); err != nil { return err }