kudulab/dojo

docker-compose invalid projectName

kief opened this issue · 2 comments

kief commented

I have a project in a folder that has capital letters in the name. When I run dojo, with the docker-compose driver, it fails with the error:

panic: Unexpected error: Command: docker-compose -f docker-compose.yml -f docker-compose.yml.dojo -p dojo-Composable-Cloud-Scaffolding-Bundle-2023-01-11_09-26-45-34825090 config --services
  Exit status: 1
  StdOut: <empty string>
  StdErr: "dojo-Composable-Cloud-Scaffolding-Bundle-2023-01-11_09-26-45-34825090" is not a valid project name

Looking through the dojo code, it seems like the folder name is used as the variable "runID", which becomes the "projectName". I'm not sure how to override this other than changing the folder name (which I will probably do, but needs some fiddling).

A suggestion would be to make a change so that the name is converted to be a valid docker-compose project name, at least where it's used in the driver. Or if there's a simpler override in the configuration, it could be added to the docs.

xmik commented

Hi Kief, thanks for letting us know!

It seems that this behaviour of docker-compose not supporting a project name with capital letters is there since docker-compose v2.6.0. Found it here: docker/compose#9519.

Looks like this behaviour in docker-compose is going to stay. So, as you suggest, we'll change dojo to make it work with newer docker-compose versions. I tested it with docker-compose version 1.27.4 and saw no errors.

xmik commented

This should be fixed now in Dojo 0.12.0.
A simple test would be to run:

$ cd test/test-files/DirWithUpperCaseLetters
$ dojo --driver=docker-compose --dcf=./itest-dc.yaml --image=alpine:3.19 sh -c "echo 1234"
2024/02/05 00:14:54 [ 1]  INFO: (main.main) Dojo version 0.12.0
2024/02/05 00:14:54 [20]  INFO: (main.DockerComposeDriver.HandleRun) docker-compose run command will be:
 docker-compose -f ./itest-dc.yaml -f ./itest-dc.yaml.dojo -p dojo-dirwithuppercaseletters-2024-02-05_00-14-54-3490228524285565300 run --rm default sh -c "echo 1234"
[+] Creating 2/0
 ✔ Network dojo-dirwithuppercaseletters-2024-02-05_00-14-54-3490228524285565300_default  Created                                                                                                              0.0s 
 ✔ Container dojo-dirwithuppercaseletters-2024-02-05_00-14-54-3490228524285565300-abc-1  Created                                                                                                              0.0s 
[+] Running 1/1
 ✔ Container dojo-dirwithuppercaseletters-2024-02-05_00-14-54-3490228524285565300-abc-1  Started                                                                                                              0.2s 
1234
2024/02/05 00:14:55 [20]  INFO: (main.DockerComposeDriver.stop) Stopping containers with command: 
docker-compose -f ./itest-dc.yaml -f ./itest-dc.yaml.dojo -p dojo-dirwithuppercaseletters-2024-02-05_00-14-54-3490228524285565300 stop
[+] Stopping 1/1
 ✔ Container dojo-dirwithuppercaseletters-2024-02-05_00-14-54-3490228524285565300-abc-1  Stopped                                                                                                              0.2s 
2024/02/05 00:14:56 [ 1]  INFO: (main.DockerComposeDriver.CleanAfterRun) Removing containers with command: 
docker-compose -f ./itest-dc.yaml -f ./itest-dc.yaml.dojo -p dojo-dirwithuppercaseletters-2024-02-05_00-14-54-3490228524285565300 down
[+] Running 2/2
 ✔ Container dojo-dirwithuppercaseletters-2024-02-05_00-14-54-3490228524285565300-abc-1  Removed                                                                                                              0.0s 
 ✔ Network dojo-dirwithuppercaseletters-2024-02-05_00-14-54-3490228524285565300_default  Removed 

Tested with Docker Compose version v2.24.5.