0

I'm running rsync through a script, but I'm not getting the progress bar. It works fine when I run it directly, but when I run the script, I only get the echoes.

In my docker-compose.yml:

command: /home/node/build-dir/command.sh
tty    : true # Show output with syntax highlighting support.
#!/bin/ash

# First check if the directory is empty, as it is when it is mounted for the first time.
if [ -z "$(ls -A /home/node/work-dir/node_modules)" ]
  then
    echo 'Beginning to copy node_modules folder...'
    # Recursively copy all files of build directory to that of the working directory.
     rsync -ah --info=progress2 /home/node/build-dir/node_modules /home/node/work-dir/node_modules
    echo 'Finished copying node_modules folder...'
  else
    echo 'The folder "node_modules" already exists; skipping copying.'
fi

# Run npm start command to start development.
exec npm start

I want it to show the progress and then stop when it finishes, finishing the script run. I want it to be as if when I run it directly through the shell using docker exec -it my_app ash and then running the following:

rsync -ah --info=progress2 /home/node/build-dir/node_modules /home/node/work-dir/node_modules

So far, I get nothing, as in it acts the same as cp. I get the two echos "Beginning to copy..." and "Finished copying..." and that's it. Where's the progress?

  • I tried to run the command through the shell on my host with test files and it worked.
  • I tried to run the script through the shell on my host with test files and it worked.
  • I tried to run the command through the shell from within the container and it worked.
  • I tried to run the script through the shell from within the container and it worked.

My only assumption is that I've done something wrong with my docker-compose.yml file.

yaharga
  • 1,743
  • 2
  • 25
  • 56
  • Docker images are supposed to be self-contained. `RUN yarn install` in your Dockerfile so that the library tree is built into the image, and you won't need to run this `rsync` command at startup time. – David Maze Jan 13 '20 at 10:57
  • @DavidMaze I'm trying to persist the `node_modules` in the container and mount it into a volume to appear on my host so I can integrate the functionalities of my IDE. Solution is taken from here: https://stackoverflow.com/a/43728476/1934402 I just need to see the progress through rsync. – yaharga Jan 13 '20 at 11:12
  • You don't want Docker for that. Just install and run Node locally, and use that for day-to-day development. (With OS and library inconsistencies it's often hard to share `node_modules` trees anyways.) – David Maze Jan 13 '20 at 11:30
  • So `rsync --progress`? – KamilCuk Jan 13 '20 at 11:34
  • @KamilCuk That shows the progress per file. I want the overall progress. – yaharga Jan 13 '20 at 11:35

1 Answers1

0

I was using docker-compose up... while I was supposed to use docker-compose run....

Source for finding my answer: Interactive shell using Docker Compose.

yaharga
  • 1,743
  • 2
  • 25
  • 56