Skip to content

Commit

Permalink
Merge pull request ekumenlabs#25 from Intermodalics/fix-do-docker-wit…
Browse files Browse the repository at this point in the history
…hout-sudo

do_docker.sh: do not run docker as root and pull optionally
  • Loading branch information
meyerj authored Nov 27, 2018
2 parents 6286bc0 + 271a4b8 commit 81ad8c8
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions do_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ del_image=0
del_tmp=0
portable=0
standard=0
pull=

if [[ $# -lt 1 ]] ; then
standard=1
Expand All @@ -33,6 +34,10 @@ do
portable=1
fi

if [[ ${var} == "--pull" ]] ; then
pull=--pull
fi

if [[ ${var} == "--raw" ]] ; then
standard=1
output_path=$my_loc"/output"
Expand All @@ -43,7 +48,7 @@ do
done

if [[ $help -eq 1 ]] ; then
echo "Usage: $0 [-h | --help] [--delete-image] [--delete-tmp] [--portable] [--standard] [output_dir]"
echo "Usage: $0 [-h | --help] [--delete-image] [--delete-tmp] [--portable] [--pull] [--standard] [output_dir]"
echo " example: $0 --raw /path/to/output/dir, will create a raw output in the desired path (only useful from Docker)"
echo " example: $0 --portable, will create a portable tar.gz output in the current directory."
echo " example: $0 --delete-image, will delete the Docker image created for the build."
Expand All @@ -56,7 +61,7 @@ if [[ $del_image -eq 1 ]]; then
echo
echo -e '\e[34mDeleting docker image.\e[39m'
echo
sudo docker rmi -f ekumenlabs/rosndk
docker rmi -f ekumenlabs/rosndk
exit $?
fi

Expand All @@ -75,21 +80,17 @@ echo
# Requires docker 1.3+
cmd_exists docker || die 'docker was not found'

echo -e '\e[34mPulling base docker image.\e[39m'
sudo docker pull ekumenlabs/rosndk


if [[ $standard -eq 1 ]]; then
echo -e '\e[34mSetting output_path to: '$output_path'.\e[39m'
echo
sudo docker run --rm=true -t -v $my_loc:/opt/roscpp_android -v $output_path:/opt/roscpp_output -i ekumenlabs/rosndk /opt/roscpp_android/do_everything.sh /opt/roscpp_output
docker run --rm=true ${pull} -t -v $my_loc:/opt/roscpp_android -v $output_path:/opt/roscpp_output -i ekumenlabs/rosndk /opt/roscpp_android/do_everything.sh /opt/roscpp_output
exit $?
fi

if [[ $portable -eq 1 ]]; then
echo -e '\e[34mBuilding in portable mode.\e[39m'
echo
sudo docker run --rm=true -t -v $my_loc:/opt/roscpp_android -v $output_path:/opt/roscpp_output -i ekumenlabs/rosndk /opt/roscpp_android/do_everything.sh /opt/roscpp_output --portable
docker run --rm=true ${pull} -t -v $my_loc:/opt/roscpp_android -v $output_path:/opt/roscpp_output -i ekumenlabs/rosndk /opt/roscpp_android/do_everything.sh /opt/roscpp_output --portable
echo
echo -e '\e[34mCreating output/roscpp_android_ndk.tar.gz.\e[39m'
echo
Expand Down

0 comments on commit 81ad8c8

Please sign in to comment.