Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

odo build-images and odo deploy do not work with Docker if optional buildContext field is not set in Devfile #5600

Closed
rm3l opened this issue Mar 29, 2022 · 0 comments · Fixed by #5657
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@rm3l
Copy link
Member

rm3l commented Mar 29, 2022

/kind bug

What versions of software are you using?

Operating System:
Fedora 35

Output of odo version:
Using the main branch.
odo v2.5.0 (36f323d)

How did you run odo exactly?

Using this Devfile, inspired from https://github.com/kadel/devfile-nodejs-deploy/blob/main/devfile.yaml

❯ mkdir -p /tmp/aname
❯ cd /tmp/aname
❯ odo init --name aname --devfile-path https://gist.githubusercontent.com/rm3l/ee9a33d87d2e650f9ba688650c8659db/raw/26c37b4dabae724f0d1a29efab53aa5e3d66b764/devfile.yaml
❯ # To force using Docker in odoexport PODMAN_CMD=a-command-not-found-should-make-odo-use-docker
❯ odo deploy -v 4
❯ odo build-images -v 4

Actual behavior

/tmp/aname on ☁️   
❯ odo init --name aname --devfile-path https://gist.githubusercontent.com/rm3l/ee9a33d87d2e650f9ba688650c8659db/raw/26c37b4dabae724f0d1a29efab53aa5e3d66b764/devfile.yaml
 ✓  Downloading devfile from "https://gist.githubusercontent.com/rm3l/ee9a33d87d2e650f9ba688650c8659db/raw/26c37b4dabae724f0d1a29efab53aa5e3d66b764/devfile.yaml" [156ms]                                                                      
                                                                                                                                                                                                                                               
Your new component "aname" is ready in the current directory.                                                                                                                                                                                  
To start editing your component, use "odo dev" and open this folder in your favorite IDE.                                                                                                                                                      
Changes will be directly reflected on the cluster.                                                                                                                                                                                             
To deploy your component to a cluster use "odo deploy". 
# To force using Docker in odoexport PODMAN_CMD=a-command-not-found-should-make-odo-use-docker
❯ odo deploy -v 4
I0329 14:21:58.925983  534901 implem.go:103] The path for preference file is /home/asoro/.odo/preference.yaml
I0329 14:21:58.926034  534901 util.go:733] HTTPGetRequest: https://raw.githubusercontent.com/redhat-developer/odo/main/build/VERSION
I0329 14:21:58.926072  534901 segment.go:254] Checking telemetry enable status
I0329 14:21:58.926083  534901 util.go:754] Response will be cached in /tmp/odohttpcache for 1h0m0s
I0329 14:21:58.926218  534901 util.go:767] Cached response used.
I0329 14:21:58.928310  534901 implem.go:103] The path for preference file is /home/asoro/.odo/preference.yaml
I0329 14:21:58.936098  534901 context.go:141] absolute devfile path: '/tmp/aname/devfile.yaml'
I0329 14:21:58.936109  534901 context.go:92] absolute devfile path: '/tmp/aname/devfile.yaml'
I0329 14:21:58.936440  534901 content.go:33] converted devfile YAML to JSON
I0329 14:21:58.936525  534901 apiVersion.go:45] devfile schemaVersion: '2.2.0'
I0329 14:21:58.936533  534901 helper.go:41] devfile apiVersion '2.2.0' is supported
I0329 14:21:58.938878  534901 schema.go:46] validated devfile schema
I0329 14:21:58.940118  534901 validate.go:45] Successfully validated devfile sections
I0329 14:21:58.940128  534901 validate.go:45] Successfully validated devfile sections
  __
 /  \__     Deploying the application using aname Devfile
 \__/  \    Namespace: default
 /  \__/    odo version: v2.5.0
 \__/

↪ Building & Pushing Container: localhost:5000/devfile-nodejs-deploy:latest
 •  Building image locally  ...
I0329 14:21:58.940309  534901 docker_compatible.go:66] Running command: docker build -t "localhost:5000/devfile-nodejs-deploy:latest" -f "/tmp/aname/Dockerfile" 
"docker build" requires exactly 1 argument.
See 'docker build --help'.

Usage:  docker build [OPTIONS] PATH | URL | -

Build an image from a Dockerfile
 ✗  Building image locally [24ms]
 ✗  error running docker command: exit status 1
❯ odo build-images -v 4
I0329 14:23:02.207365  536569 implem.go:103] The path for preference file is /home/asoro/.odo/preference.yaml
I0329 14:23:02.207434  536569 util.go:733] HTTPGetRequest: https://raw.githubusercontent.com/redhat-developer/odo/main/build/VERSION
I0329 14:23:02.207456  536569 segment.go:254] Checking telemetry enable status
I0329 14:23:02.207472  536569 util.go:754] Response will be cached in /tmp/odohttpcache for 1h0m0s
I0329 14:23:02.207564  536569 context.go:141] absolute devfile path: '/tmp/aname/devfile.yaml'
I0329 14:23:02.207576  536569 context.go:92] absolute devfile path: '/tmp/aname/devfile.yaml'
I0329 14:23:02.207600  536569 util.go:767] Cached response used.
I0329 14:23:02.207823  536569 content.go:33] converted devfile YAML to JSON
I0329 14:23:02.207875  536569 apiVersion.go:45] devfile schemaVersion: '2.2.0'
I0329 14:23:02.207880  536569 helper.go:41] devfile apiVersion '2.2.0' is supported
I0329 14:23:02.210673  536569 schema.go:46] validated devfile schema
I0329 14:23:02.211911  536569 validate.go:45] Successfully validated devfile sections
I0329 14:23:02.211921  536569 validate.go:45] Successfully validated devfile sections

↪ Building & Pushing Container: localhost:5000/devfile-nodejs-deploy:latest
 •  Building image locally  ...
I0329 14:23:02.212043  536569 docker_compatible.go:66] Running command: docker build -t "localhost:5000/devfile-nodejs-deploy:latest" -f "/tmp/aname/Dockerfile" 
"docker build" requires exactly 1 argument.
See 'docker build --help'.

Usage:  docker build [OPTIONS] PATH | URL | -

Build an image from a Dockerfile
 ✗  Building image locally [24ms]
 ✗  error running docker command: exit status 1

Expected behavior

The documentation states that:

The buildContext indicates the directory used as build context. The default value is ${PROJECT_SOURCE}.

If I understand correctly, buildContext should be an optional field defaulting to ${PROJECT_SOURCE}.
So I think we should support this default value if not set. Or, if required, exit with an appropriate error message.

I came across this issue when working on #5322, but I preferred to separate the issues / PRs.

@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Mar 29, 2022
@rm3l rm3l changed the title odo build-images and odo deploy do not work when using Docker if optional buildContext field is not set in Devfile odo build-images and odo deploy do not work with Docker if optional buildContext field is not set in Devfile Mar 29, 2022
@joshira-rh joshira-rh moved this to In Progress in odo v3-beta1 Apr 12, 2022
@rm3l rm3l moved this from In Progress to For Review in odo v3-beta1 Apr 14, 2022
openshift-merge-robot pushed a commit that referenced this issue Apr 19, 2022
… optional `buildContext` field is not set in Devfile (#5600) (#5657)

* Add unit test highlighting the issue

* Add integration tests to both `build-images` and `deploy` highlighting the issue

* Use the Devfile directory as default build context path if not defined

Per the Devfile spec [1], `buildContext` should be optional.

[1] https://devfile.io/docs/devfile/2.2.0/user-guide/api-reference/

* Quote the build context path value
Repository owner moved this from For Review to Done in odo v3-beta1 Apr 19, 2022
cdrage pushed a commit to cdrage/odo that referenced this issue Aug 31, 2022
… optional `buildContext` field is not set in Devfile (redhat-developer#5600) (redhat-developer#5657)

* Add unit test highlighting the issue

* Add integration tests to both `build-images` and `deploy` highlighting the issue

* Use the Devfile directory as default build context path if not defined

Per the Devfile spec [1], `buildContext` should be optional.

[1] https://devfile.io/docs/devfile/2.2.0/user-guide/api-reference/

* Quote the build context path value
@rm3l rm3l added the v3 label Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
No open projects
Status: Done
1 participant