launchrctl / launchr

Launchr is a CLI action runner that executes actions inside short-lived local containers.
Apache License 2.0
10 stars 2 forks source link

Ability to use volume from working dir #12

Closed davidferlay closed 9 months ago

davidferlay commented 9 months ago

Context

Observed

Expected

It may be a good thing to bring this with a launchr plugin

lexbritvin commented 9 months ago

Implemented --use-volume-wd flag, to me, the name better represents the behavior than in the request. I didn't make shorthand -m as currently it's a bit complex to mix options for actions and other and have no conflicts in definition. We will need to address that later, because we may need aliases for action options also.

The code in the main branch, I didn't prepare a release just yet.

davidferlay commented 9 months ago

Looking good !

Creating release

image

davidferlay commented 9 months ago

After further test, it looks like there is an issue with permission.

➜ lauchrctl platform:test -vvv --use-volume-wd                                                      
DEBUG: Starting execution of the action "platform:test" in "docker" environment, command [sh /action/main.sh]
Image "platform-actions-compare-artifact:latest" exists locally
INFO: Image "platform-actions-compare-artifact:latest" exists locally
Flag "--use-volume-wd" is set. Copying the working directory inside the container.
+ pwd
/host
+ ls -lah /
+ grep host
drwxr-xr-x    1 root     root         532 Dec  5 14:46 host
+ id
uid=1000(plasma) gid=1000(plasma) groups=1000(plasma)
+ rm -rf new_file
/action/main.sh: line 7: can't create new_file: Permission denied
DEBUG: [hijack] End of stdout
DEBUG: Error resize: Error response from daemon: container d14a3aeb75802f782969bfd02d6e9522531b3cfee26caf5dc5d542fdb2a4f0cb is not running
DEBUG: Error resize: Error response from daemon: No such container: d14a3aeb75802f782969bfd02d6e9522531b3cfee26caf5dc5d542fdb2a4f0cb
DEBUG: Error resize: Error response from daemon: No such container: d14a3aeb75802f782969bfd02d6e9522531b3cfee26caf5dc5d542fdb2a4f0cb
DEBUG: Error resize: Error response from daemon: No such container: d14a3aeb75802f782969bfd02d6e9522531b3cfee26caf5dc5d542fdb2a4f0cb
DEBUG: Error resize: Error response from daemon: No such container: d14a3aeb75802f782969bfd02d6e9522531b3cfee26caf5dc5d542fdb2a4f0cb
DEBUG: Error resize: Error response from daemon: No such container: d14a3aeb75802f782969bfd02d6e9522531b3cfee26caf5dc5d542fdb2a4f0cb
DEBUG: Error resize: Error response from daemon: No such container: d14a3aeb75802f782969bfd02d6e9522531b3cfee26caf5dc5d542fdb2a4f0cb
DEBUG: Error resize: Error response from daemon: No such container: d14a3aeb75802f782969bfd02d6e9522531b3cfee26caf5dc5d542fdb2a4f0cb
DEBUG: Error resize: Error response from daemon: No such container: d14a3aeb75802f782969bfd02d6e9522531b3cfee26caf5dc5d542fdb2a4f0cb
DEBUG: Error resize: Error response from daemon: No such container: d14a3aeb75802f782969bfd02d6e9522531b3cfee26caf5dc5d542fdb2a4f0cb
DEBUG: Error resize: Error response from daemon: No such container: d14a3aeb75802f782969bfd02d6e9522531b3cfee26caf5dc5d542fdb2a4f0cb
failed to resize tty, using default size
INFO: action "platform:test" finished with the exit code 1

➜ launchrctl platform:test -vvv
DEBUG: Starting execution of the action "platform:test" in "docker" environment, command [sh /action/main.sh] Image "platform-actions-compare-artifact:latest" exists locally INFO: Image "platform-actions-compare-artifact:latest" exists locally



Action used for this test : [test.tar.gz](https://github.com/launchrctl/launchr/files/13561582/test.tar.gz)
davidferlay commented 9 months ago

Working as expected :ok_hand:

➜ docker rmi test:latest; launchrctl platform:test -vvv --use-volume-wd        
rm: cannot remove 'new_file': No such file or directory                                       
Error response from daemon: No such image: test:latest
DEBUG: Starting execution of the action "platform:test" in "docker" environment, command [sh /action/main.sh]
Image "platform-actions-compare-artifact:latest" exists locally
INFO: Image "platform-actions-compare-artifact:latest" exists locally
Flag "--use-volume-wd" is set. Copying the working directory inside the container.
+ rm -rf new_file
+ ls -lah
+ grep new_file
-rw-r--r--    1 plasma   plasma         4 Dec  7 10:47 new_file
DEBUG: [hijack] End of stdout
INFO: action "platform:test" finished with the exit code 0
Flag "--use-volume-wd" is set. Copying back the result of the action run.

➜ ls -lah | grep "new_file"
-rw-r--r--  1 dferlay dferlay    4 Dec  7 11:47 new_file