zrhoffman commented on a change in pull request #5004:
URL: https://github.com/apache/trafficcontrol/pull/5004#discussion_r536335335



##########
File path: pkg
##########
@@ -156,12 +175,28 @@ while (( "$#" )); do
                if (( "$verbose" == 0 )); then
                        exec >/dev/null 2>&1
                fi
+
+               # Build the project
                if [[ $build_images -eq 1 ]]; then
                        "${COMPOSECMD[@]}" -f $COMPOSE_FILE build $1 || exit 1
                else
                        "${COMPOSECMD[@]}" -f $COMPOSE_FILE pull $1 || exit 1
                fi
                "${COMPOSECMD[@]}" -f $COMPOSE_FILE run "${RUN_OPTIONS[@]}" 
--rm $1 || exit 1
+
+               # Check for a chained compose file for this particular project.
+               # A chained compose file will be named exactly the same as main 
docker-compose, with .service added,
+               # where <service> is the name of the specific service to be 
chained. The file may be a symlink to another
+               # compose file, in which case the symlink will be followed 
before it is processed.
+               # A "dist" symlink will be temporarily created in that 
directory to facilitate the collation of artefacts.
+               if [ -e "$COMPOSE_FILE.$1" ] ; then
+                       ln -sf "$(dirname -- "$(realpath -e -- "$SELF")")/dist" 
"$(dirname -- "$(realpath -e -- "$COMPOSE_FILE.$1")")/dist" || exit 1
+                       $SELF -f $(realpath -e "$COMPOSE_FILE.$1") $([ 
"$verbose" == 0 ] || echo "-v") $([ "$quiet" == 0 ] || echo "-q") $([ "$debug" 
== 0 ] || echo "-d") $([ "$build" == 0 ] || echo "-b") $("${COMPOSECMD[@]}" -f 
$(realpath -e "$COMPOSE_FILE.$1") config --services) || exit 1
+                       rm "$(dirname -- "$(realpath -e -- 
"$COMPOSE_FILE.$1")")/dist"

Review comment:
       The symlink is only removed if the build succeeds. It should be removed 
after building in all cases. One way to accomplish this is to wrap these lines 
in a subshell, then trap the `dist` symlink removal like
   
   ```shell
   trap 'rm "$(dirname -- "$(realpath -e -- "$COMPOSE_FILE.$1")")/dist"' EXIT
   ```
   
   so that `dist` is removed when the subshell exits.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to