Closed kadel closed 6 years ago
@kadel it will be a good addition to libcompose itself
libcompose supports that
So should we work on this or wait till we swap openshift's libcompose with upstream libcompose?
swapping to upstream libcompose won't help
from my investigation it seems that this is actually intentional and it is how openshift import has been written. look at this: https://github.com/redhat-developer/henge/blob/master/pkg/transformers/openshift/generate.go#L145,L178
@kadel one finding openshift's libcompose code itself will expand the Build variable, so after p.Parse()
if you look for p.Configs[svc_name].Build
it will be changed from relative path to absolute path.
I checked with upstream libcompose, it worked with both absolute path and relative path.
Using absolute path for build in docker-compose file
Using relative path in docker compose file
Reported issue in origin https://github.com/openshift/origin/issues/9815
Doing deeper research on libcompose's way of handling the parsed config is quite different, so libcompose stores path to build directory as is given by user. And build information is stored in object of type Build
.
(dlv) b /home/vagrant/work/src/github.com/docker/libcompose/project/project.go:178
(dlv) c
(dlv) p serviceConfigs["etherpad"]
*github.com/docker/libcompose/config.ServiceConfig {
Build: github.com/docker/libcompose/yaml.Build {
Context: "./myphp",
Dockerfile: "",
Args: map[string]string [],},
CapAdd: []string len: 0, cap: 0, [],
CapDrop: []string len: 0, cap: 0, [],
CPUSet: "",
[SNIP]
While openshift's libcompose will only store absolute path to build path.
(dlv) b /home/vagrant/work/src/github.com/redhat-developer/henge/pkg/transformers/openshift/generate.go:63
(dlv) c
(dlv) p p.Configs["etherpad"]
*github.com/redhat-developer/henge/vendor/github.com/openshift/origin/third_party/github.com/docker/libcompose/project.ServiceConfig {
Build: "/home/vagrant/compose-lib/etherpad/myphp",
CapAdd: []string len: 0, cap: 0, [],
[SNIP]
Currently
build
in docker compose file is expected to be relative path. We also need support absolute path, urls, andcontext
withdockerfile
options. see: https://docs.docker.com/compose/compose-file/