Merge pull request #499 from surajnarwade/add_dockerfile_support

Added dockerfile key support
This commit is contained in:
Charlie Drage 2017-03-22 10:17:10 -04:00 committed by GitHub
commit 3ac6d9aa58
4 changed files with 8 additions and 3 deletions

View File

@ -84,6 +84,7 @@ type ServiceConfig struct {
Tty bool `compose:"tty" bundle:""` Tty bool `compose:"tty" bundle:""`
MemLimit yaml.MemStringorInt `compose:"mem_limit" bundle:""` MemLimit yaml.MemStringorInt `compose:"mem_limit" bundle:""`
TmpFs []string `compose:"tmpfs" bundle:""` TmpFs []string `compose:"tmpfs" bundle:""`
Dockerfile string `compose:"dockerfile" bundle:""`
} }
// EnvVar holds the environment variable struct of a container // EnvVar holds the environment variable struct of a container

View File

@ -76,7 +76,6 @@ func checkUnsupportedKey(composeProject *project.Project) []string {
"Uts": false, "Uts": false,
"ReadOnly": false, "ReadOnly": false,
"Ulimits": false, "Ulimits": false,
"Dockerfile": false,
"Net": false, "Net": false,
"Sysctls": false, "Sysctls": false,
"Networks": false, // there are special checks for Network in checkUnsupportedKey function "Networks": false, // there are special checks for Network in checkUnsupportedKey function
@ -321,6 +320,7 @@ func (c *Compose) LoadFile(files []string) (kobject.KomposeObject, error) {
serviceConfig.ContainerName = composeServiceConfig.ContainerName serviceConfig.ContainerName = composeServiceConfig.ContainerName
serviceConfig.Command = composeServiceConfig.Entrypoint serviceConfig.Command = composeServiceConfig.Entrypoint
serviceConfig.Args = composeServiceConfig.Command serviceConfig.Args = composeServiceConfig.Command
serviceConfig.Dockerfile = composeServiceConfig.Build.Dockerfile
envs := loadEnvVars(composeServiceConfig.Environment) envs := loadEnvVars(composeServiceConfig.Environment)
serviceConfig.Environment = envs serviceConfig.Environment = envs

View File

@ -200,7 +200,9 @@ func initBuildConfig(name string, service kobject.ServiceConfig, composeFileDir
ContextDir: contextDir, ContextDir: contextDir,
}, },
Strategy: buildapi.BuildStrategy{ Strategy: buildapi.BuildStrategy{
DockerStrategy: &buildapi.DockerBuildStrategy{}, DockerStrategy: &buildapi.DockerBuildStrategy{
DockerfilePath: service.Dockerfile,
},
}, },
Output: buildapi.BuildOutput{ Output: buildapi.BuildOutput{
To: &kapi.ObjectReference{ To: &kapi.ObjectReference{

View File

@ -290,7 +290,8 @@ func TestInitBuildConfig(t *testing.T) {
repo := "https://git.test.com/org/repo" repo := "https://git.test.com/org/repo"
branch := "somebranch" branch := "somebranch"
sc := kobject.ServiceConfig{ sc := kobject.ServiceConfig{
Build: "./build", Build: "./build",
Dockerfile: "Dockerfile-alternate",
} }
bc, err := initBuildConfig(serviceName, sc, composeFileDir, repo, branch) bc, err := initBuildConfig(serviceName, sc, composeFileDir, repo, branch)
if err != nil { 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 git Ref": {bc.Spec.CommonSpec.Source.Git.Ref, branch},
"Assert buildconfig source context dir": {bc.Spec.CommonSpec.Source.ContextDir, "a/build"}, "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 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 { for name, test := range testCases {