mirror of
https://github.com/containers/podman.git
synced 2025-06-23 18:59:30 +08:00
Merge pull request #11675 from baude/playkubebuildcontextdir
Set context dir for play kube build
This commit is contained in:
@ -435,6 +435,7 @@ func (ic *ContainerEngine) getImageAndLabelInfo(ctx context.Context, cwd string,
|
|||||||
buildOpts.Isolation = buildahDefine.IsolationChroot
|
buildOpts.Isolation = buildahDefine.IsolationChroot
|
||||||
buildOpts.CommonBuildOpts = commonOpts
|
buildOpts.CommonBuildOpts = commonOpts
|
||||||
buildOpts.Output = container.Image
|
buildOpts.Output = container.Image
|
||||||
|
buildOpts.ContextDirectory = filepath.Dir(buildFile)
|
||||||
if _, _, err := ic.Libpod.Build(ctx, *buildOpts, []string{buildFile}...); err != nil {
|
if _, _, err := ic.Libpod.Build(ctx, *buildOpts, []string{buildFile}...); err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -80,12 +80,17 @@ status: {}
|
|||||||
FROM quay.io/libpod/alpine_nginx:latest
|
FROM quay.io/libpod/alpine_nginx:latest
|
||||||
RUN apk update && apk add strace
|
RUN apk update && apk add strace
|
||||||
LABEL homer=dad
|
LABEL homer=dad
|
||||||
|
COPY copyfile /copyfile
|
||||||
`
|
`
|
||||||
var prebuiltImage = `
|
var prebuiltImage = `
|
||||||
FROM quay.io/libpod/alpine_nginx:latest
|
FROM quay.io/libpod/alpine_nginx:latest
|
||||||
RUN apk update && apk add strace
|
RUN apk update && apk add strace
|
||||||
LABEL marge=mom
|
LABEL marge=mom
|
||||||
`
|
`
|
||||||
|
|
||||||
|
var copyFile = `just a text file
|
||||||
|
`
|
||||||
|
|
||||||
It("Check that image is built using Dockerfile", func() {
|
It("Check that image is built using Dockerfile", func() {
|
||||||
// Setup
|
// Setup
|
||||||
yamlDir := filepath.Join(tempdir, RandomString(12))
|
yamlDir := filepath.Join(tempdir, RandomString(12))
|
||||||
@ -97,7 +102,9 @@ LABEL marge=mom
|
|||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
err = writeYaml(playBuildFile, filepath.Join(app1Dir, "Dockerfile"))
|
err = writeYaml(playBuildFile, filepath.Join(app1Dir, "Dockerfile"))
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
// Write a file to be copied
|
||||||
|
err = writeYaml(copyFile, filepath.Join(app1Dir, "copyfile"))
|
||||||
|
Expect(err).To(BeNil())
|
||||||
// Switch to temp dir and restore it afterwards
|
// Switch to temp dir and restore it afterwards
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
@ -131,7 +138,9 @@ LABEL marge=mom
|
|||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
err = writeYaml(playBuildFile, filepath.Join(app1Dir, "Containerfile"))
|
err = writeYaml(playBuildFile, filepath.Join(app1Dir, "Containerfile"))
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
// Write a file to be copied
|
||||||
|
err = writeYaml(copyFile, filepath.Join(app1Dir, "copyfile"))
|
||||||
|
Expect(err).To(BeNil())
|
||||||
// Switch to temp dir and restore it afterwards
|
// Switch to temp dir and restore it afterwards
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
@ -172,6 +181,9 @@ LABEL marge=mom
|
|||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
err = writeYaml(playBuildFile, filepath.Join(app1Dir, "Containerfile"))
|
err = writeYaml(playBuildFile, filepath.Join(app1Dir, "Containerfile"))
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
// Write a file to be copied
|
||||||
|
err = writeYaml(copyFile, filepath.Join(app1Dir, "copyfile"))
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
// Switch to temp dir and restore it afterwards
|
// Switch to temp dir and restore it afterwards
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
@ -215,6 +227,9 @@ LABEL marge=mom
|
|||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
err = writeYaml(playBuildFile, filepath.Join(app1Dir, "Containerfile"))
|
err = writeYaml(playBuildFile, filepath.Join(app1Dir, "Containerfile"))
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
// Write a file to be copied
|
||||||
|
err = writeYaml(copyFile, filepath.Join(app1Dir, "copyfile"))
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
// Switch to temp dir and restore it afterwards
|
// Switch to temp dir and restore it afterwards
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
|
Reference in New Issue
Block a user