Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 154 additions & 0 deletions docker/solution/build_comp_image.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
#! /usr/bin/env bash
#
# Space Robotics Competition 2: NASA JSC
# Copyright (c), 2019-2021 NASA-JSC. All Rights Reserved
# Unauthorized distribution strictly prohibited
#
#
pushd `pwd` > /dev/null 2>&1
cd $(cd -P -- "$(dirname -- "$0")" && pwd -P)
source "../../srcp2-competitors/docker/scripts/srcp2_setup.bash"

# ----------------------------------------------------------------------------------------------------------------------
# CONSTANTS AND NAMES
#
BUILD_CONTEXT=$( cd "../../"; pwd) # the repo root
DOCKER_BUILD_ARGS=""
#
BUILD_LOG="/tmp/docker-build-log.txt"
OUTPUT_LOG=" > $BUILD_LOG 2>&1"
VERBOSE=0
# Solution
DOCKER_SUBMIT_REPO="scheducation/srcp2_comp_solutions"
DOCKER_SUBMIT_TAG="swarmathon"

# Base Line
DOCKER_BASE_REPO="scheducation/srcp2_comp"
DOCKER_BASE_TAG="final_competitor"
#


# ----------------------------------------------------------------------------------------------------------------------
# UTILITY FUNCTIONS
#

function help(){
echo -e "
${B}Synopsis:${rs}

Build the the solution docker images this project relies upon.
By default, this will build everything, you can specify
which image sets you build

${B}Options:${rs}

${B}-h | --help${rs}
print this message and quit

${B}-n | --new${rs}
build any clean (--no-cache). This forces total rebuild and
will be slow!

${B}-t | --team${rs}
the Team Name Tag in the submision docker hub repo if not
provided the defaults to team_omega a developer test image

${B}-v | --verbose${rs}
build verbose, show all docker outputs to stdout
"
}

function test_build_ok() {
if [ $1 -ne 0 ]; then
echo -e "$echo_error could not build image for ${r}$2${rs}"
echo
if [ $VERBOSE -eq 0 ]; then
cat $3
fi
return $1
else
echo -e "$echo_ok completed build ${b}$2${rs}"
return 0
fi
}

# ----------------------------------------------------------------------------------------------------------------------
#
function build_solution_images() {

tag="${DOCKER_SUBMIT_REPO}:${DOCKER_SUBMIT_TAG}"
echo -e "$echo_info building ${b}$tag${rs}"
docker build ${DOCKER_BUILD_ARGS} \
--file solution.dockerfile \
--tag $tag \
--build-arg base_image=${DOCKER_BASE_REPO}:${DOCKER_BASE_TAG} \
\
$BUILD_CONTEXT

if ! test_build_ok $? $tag $BUILD_LOG; then return 1; fi
echo

return 0
}


# ----------------------------------------------------------------------------------------------------------------------
# MAIN PROGRAM

echo_header

# long opts to short opts
for arg in "$@"; do
shift
case "$arg" in
"--help") set -- "$@" "-h" ;;
"--team") set -- "$@" "-t" ;;
"--new") set -- "$@" "-n" ;;
"--verbose") set -- "$@" "-v" ;;
*) set -- "$@" "$arg"
esac
done

OPTIND=1
while getopts hnvt: arg; do
case $arg in

h)
help
quit_with_popd 0
;;
n)
DOCKER_BUILD_ARGS="--no-cache"
echo -e "$echo_info Forcing from-scratch rebuild. This will be slow!"
;;
v)
VERBOSE=1
echo -e "$echo_info Building in verbose mode"
;;

t)
if [ -z ${OPTARG} ]; then
DOCKER_SUBMIT_TAG=$DOCKER_SUBMIT_TAG
else
DOCKER_SUBMIT_TAG=$OPTARG
fi
;;
*)
echo -e "$echo_error Input option \"$arg\" not supported at this time. see '-h' for help"
quit_with_popd 1
;;
esac
done

echo -e "$echo_info Build Parameters:"
echo -e "$echo_info \tDocker build context = $(cd $BUILD_CONTEXT; pwd)"
echo -e "$echo_info \tBuild Log = $BUILD_LOG"
echo

if ! build_solution_images; then
quit_with_popd $?;
fi
echo -e "$echo_info Solution Image Detail : ${b}${DOCKER_SUBMIT_REPO}:${DOCKER_SUBMIT_TAG}${rs}"
echo -e "\n$echo_ok Solution Image Built."

quit_with_popd 0
Empty file.
22 changes: 22 additions & 0 deletions docker/solution/container/solution-entrypoint.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#! /usr/bin/env bash
#
# Space Robotics Competition 2: NASA JSC
# Copyright (c), 2019-2021 NASA-JSC. All Rights Reserved
#

# system setups
source "/opt/ros/$ROS_DISTRO/setup.bash"
source "/usr/share/gazebo/setup.sh"

# set up srcp2 extras
source ~/scripts/srcp2_setup.bash

# Source ROS Worspaces
source $HOME/ros_workspace/install/setup.bash
source $HOME/cmp_workspace/install/setup.bash

roslaunch scoot scoot.launch "mode:=man" "name:=small_scout_1"
# run example solution
rosrun scoot repl.py

exit $?
79 changes: 79 additions & 0 deletions docker/solution/solution.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#
# Space Robotics Challenge 2: NASA JSC
# Final Round
#
# Copyright (c), 2019-2022 NASA-JSC. All Rights Reserved
# Unauthorized Distribution Strictly Prohibited
#
ARG base_image="final_competitor"
FROM ${base_image}
# *******************************************
# ** COMPETITOR CUSTOMIZATION THIS LIST **
# ** DELIMITED ITEMS WITH SPACE CHARACTER! **

# OS Level Apps (all will be installed root permissions)
# These boxes and figlet, flask are optional are just here as examples
ARG os_apps="apt-utils \
build-essential \
ros-noetic-tf \
ros-noetic-angles \
ros-noetic-gazebo-msgs \
ros-noetic-robot-localization \
ros-noetic-stereo-image-proc \
ros-noetic-gazebo-ros \
ros-noetic-geometry2 \
python3-catkin-tools \
python3-osrf-pycommon \
python3 \
python3-pip"

# Python Plugins
ARG py_apps="ipython future imutils scipy"
# ** COMPETITOR CUSTOMIZATION THIS LIST DONE **
# *********************************************

ARG enduser_name="srcp2"

USER root
# The apts
RUN apt-get update && apt-get install -y; \
for app in $req_os_apps; do \
apt-get install $app -y; \
done;
# The python
RUN for py in $req_py_apps; do \
pip3 install $py; \
done;

# Make Home Folder Tree Proper Permissions ** THESE ARE REQUIRED **
# copy in the "binary" & src versions of all the ROS packages
# User Level
USER ${enduser_name}
RUN mkdir -p -v /home/$enduser_name/cmp_workspace
COPY --chown=${enduser_name}:${enduser_name} ./srcp2-competitors/cmp_workspace/install ${HOME}/cmp_workspace/install/
COPY --chown=${enduser_name}:${enduser_name} . ${HOME}/cmp_workspace/src

# ******************************************
# ** COMPETITOR CUSTOMIZATION HERE! **
# The Competitor Can Add More Docker Customization Commands Here
# Refer to Docker Documentation for this.
# RUN zzz
# COPY zzz
#
# ******************************************

# Root Level Permissions
USER root
RUN chown -R "${enduser_name}:${enduser_name}" "/home/${enduser_name}";\
ls -la "/home/${enduser_name}"

# User Level Permissions
USER ${enduser_name}

# Entrypoint and Config Copies ** THESE ARE REQUIRED **
COPY docker/solution/container/solution-entrypoint.bash ${HOME}/scripts
COPY docker/solution/container/config_solution.yaml ${HOME}/config

# starting conditions (note: CMD not ENTRYPOINT for --interactive override)
ENV SOLUTION_ENTRYPOINT="${HOME}/scripts/solution-entrypoint.bash"
CMD ${SOLUTION_ENTRYPOINT}