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

Option to remove docker image built after execution #14

Closed davidferlay closed 8 months ago

davidferlay commented 9 months ago

Observed

Expected

image

Expected

iignatevich commented 9 months ago

https://github.com/launchrctl/launchr/pull/15

davidferlay commented 9 months ago

Working fine with ./launchr_Linux_x86_64 platform:test --remove-image

Image "platform-actions-compare-artifact:latest" doesn't exist locally, building...
Step 1/9 : FROM alpine:3.18
 ---> b541f2080109
Step 2/9 : RUN apk update --no-cache --quiet &&     apk upgrade --no-cache -a
 ---> Using cache
 ---> 99a1764c2f7e
Step 3/9 : RUN apk add --no-cache --quiet git curl diffutils
 ---> Using cache
 ---> 58090ed0f82a
Step 4/9 : ARG USER_ID
 ---> Using cache
 ---> 32378c4337e7
Step 5/9 : ARG GROUP_ID
 ---> Using cache
 ---> a9d4e745289f
Step 6/9 : RUN echo ${USER_ID}
 ---> Using cache
 ---> ec27ced977b0
Step 7/9 : RUN echo ${GROUP_ID}
 ---> Using cache
 ---> 76032574ec1b
Step 8/9 : RUN adduser -D -u $USER_ID -g $GROUP_ID plasma || true
 ---> Using cache
 ---> 328f01dd60b3
Step 9/9 : USER plasma
 ---> Running in 1494f6cc0298
 ---> 80cc5d6aed2b
Successfully built 80cc5d6aed2b
Successfully tagged platform-actions-compare-artifact:latest
+ pwd
/host
+ ls -lah /
+ grep host
drwxrwxrwx    1 plasma   plasma       566 Dec  5 15:07 host
+ id
uid=1000(plasma) gid=1000(plasma) groups=1000(plasma)
+ rm -rf new_file
+ echo YAY
+ ls -lah
+ grep new_file
-rw-r--r--    1 plasma   plasma         4 Dec  5 15:08 new_file
Image "platform-actions-compare-artifact:latest" was successfuly removed

~However, I believe it would be better to have that behavior by default, and have an option to keep built image~

davidferlay commented 9 months ago

In certain cases, it fails :

launchrctl platform:components-update-propagate ${PLASMA_BUILD_ENV} file.diff --vaultpass "${PLASMACTL_VAULT_PW}" --use-volume-wd --remove-image
Image "platform-actions-components-update-propagate:latest" doesn't exist locally, building...
Step 1/11 : FROM alpine:3.18
 ---> 8ca4688f4f35
(...)
Step 11/11 : USER ${USER_NAME}
 ---> Running in 1d5698aafa0f
 ---> 8e118c06037d
Successfully built 8e118c06037d
Successfully tagged platform-actions-components-update-propagate:latest
Flag "--use-volume-wd" is set. Copying the working directory inside the container.
(...)
Flag "--use-volume-wd" is set. Copying back the result of the action run.
ERROR: Image remove returned an error: Error response from daemon: conflict: unable to remove repository reference "platform-actions-components-update-propagate:latest" (must force) - container e2793357384d is using its referenced image 8e118c06037d

Manually executing docker rmi platform-actions-compare-artifact on server after job was finished was successful

So it looks like a timing issue, maybe need to wait for image not to be used anymore