Added dockerfile key support
Fixes #486 This commit will add `dockerfilepath` key under Dockerstratergy in buildconfig. dockerfilepath allow us to use dockerfiles which are named different than `Dockerfile` which are placed in context directory. for example, for a docker-compose file: ``` version: "2" services: foo: build: context: "./build" dockerfile: "Dockerfile-alternate" command: "sleep 3600" ``` Resulting buildconfig will be: ``` apiVersion: v1 kind: BuildConfig ... ... strategy: dockerStrategy: dockerfilePath: Dockerfile-alternate type: Docker ... ... ```
This commit is contained in:
@@ -200,7 +200,9 @@ func initBuildConfig(name string, service kobject.ServiceConfig, composeFileDir
|
||||
ContextDir: contextDir,
|
||||
},
|
||||
Strategy: buildapi.BuildStrategy{
|
||||
DockerStrategy: &buildapi.DockerBuildStrategy{},
|
||||
DockerStrategy: &buildapi.DockerBuildStrategy{
|
||||
DockerfilePath: service.Dockerfile,
|
||||
},
|
||||
},
|
||||
Output: buildapi.BuildOutput{
|
||||
To: &kapi.ObjectReference{
|
||||
|
||||
@@ -290,7 +290,8 @@ func TestInitBuildConfig(t *testing.T) {
|
||||
repo := "https://git.test.com/org/repo"
|
||||
branch := "somebranch"
|
||||
sc := kobject.ServiceConfig{
|
||||
Build: "./build",
|
||||
Build: "./build",
|
||||
Dockerfile: "Dockerfile-alternate",
|
||||
}
|
||||
bc, err := initBuildConfig(serviceName, sc, composeFileDir, repo, branch)
|
||||
if err != nil {
|
||||
@@ -305,6 +306,7 @@ func TestInitBuildConfig(t *testing.T) {
|
||||
"Assert buildconfig source git Ref": {bc.Spec.CommonSpec.Source.Git.Ref, branch},
|
||||
"Assert buildconfig source context dir": {bc.Spec.CommonSpec.Source.ContextDir, "a/build"},
|
||||
"Assert buildconfig output name": {bc.Spec.CommonSpec.Output.To.Name, serviceName + ":latest"},
|
||||
"Assert buildconfig dockerfilepath": {bc.Spec.CommonSpec.Strategy.DockerStrategy.DockerfilePath, "Dockerfile-alternate"},
|
||||
}
|
||||
|
||||
for name, test := range testCases {
|
||||
|
||||
Reference in New Issue
Block a user