Skip to content

Commit

Permalink
Update Docker setup
Browse files Browse the repository at this point in the history
Signed-off-by: Andrej Orsula <orsula.andrej@gmail.com>
  • Loading branch information
AndrejOrsula committed Jul 31, 2022
1 parent 43e4c56 commit d4923c5
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 9 deletions.
8 changes: 4 additions & 4 deletions .docker/build.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env bash

TAG="andrejorsula/drl_grasping"
SCRIPT_DIR="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" &>/dev/null && pwd)"
PROJECT_DIR="$(dirname "${SCRIPT_DIR}")"

TAG="andrejorsula/$(basename "${PROJECT_DIR}")"

if [ "${#}" -gt "0" ]; then
if [[ "${1}" != "-"* ]]; then
Expand All @@ -11,9 +14,6 @@ if [ "${#}" -gt "0" ]; then
fi
fi

SCRIPT_DIR="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" &>/dev/null && pwd)"
PROJECT_DIR="$(dirname "${SCRIPT_DIR}")"

DOCKER_BUILD_CMD=(
docker build
"${PROJECT_DIR}"
Expand Down
13 changes: 13 additions & 0 deletions .docker/devel.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

SCRIPT_DIR="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" &>/dev/null && pwd)"
PROJECT_DIR="$(dirname "${SCRIPT_DIR}")"

DOCKER_HOME="/root"
DOCKER_WS_DIR="${DOCKER_HOME}/ws"
DOCKER_WS_SRC_DIR="${DOCKER_WS_DIR}/src"
DOCKER_TARGET_SRC_DIR="${DOCKER_WS_SRC_DIR}/$(basename "${PROJECT_DIR}")"

echo -e "\033[2;37mDevelopment volume: ${PROJECT_DIR} -> ${DOCKER_TARGET_SRC_DIR}\033[0m" | xargs

exec "${SCRIPT_DIR}/run.bash" -v "${PROJECT_DIR}:${DOCKER_TARGET_SRC_DIR}" "${@}"
18 changes: 16 additions & 2 deletions .docker/run.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

TAG="andrejorsula/drl_grasping"

## Forward custom volumes and environment variables
CUSTOM_VOLUMES=()
CUSTOM_ENVS=()
while getopts ":v:e:" opt; do
case "${opt}" in
v) CUSTOM_VOLUMES+=("${OPTARG}") ;;
e) CUSTOM_ENVS+=("${OPTARG}") ;;
*)
echo >&2 "Usage: ${0} [-v VOLUME] [-e ENV] [TAG] [CMD]"
exit 2
;;
esac
done
shift "$((OPTIND - 1))"

## Determine TAG and CMD positional arguments
if [ "${#}" -gt "0" ]; then
if [[ $(docker images --format "{{.Tag}}" "${TAG}") =~ (^|[[:space:]])${1}($|[[:space:]]) || $(wget -q https://registry.hub.docker.com/v2/repositories/${TAG}/tags -O - | grep -Poe '(?<=(\"name\":\")).*?(?=\")') =~ (^|[[:space:]])${1}($|[[:space:]]) ]]; then
# Use the first argument as a tag is such tag exists either locally or on the remote registry
Expand Down Expand Up @@ -48,14 +64,12 @@ GUI_ENVS=(
)

## Additional volumes
CUSTOM_VOLUMES=()
# Synchronize timezone with host
CUSTOM_VOLUMES+=("/etc/localtime:/etc/localtime:ro")
# Persistent storage of logs
CUSTOM_VOLUMES+=("${PWD}/drl_grasping_training_docker:/root/drl_grasping_training")

## Additional environment variables
CUSTOM_ENVS=()
# Synchronize ROS_DOMAIN_ID with host
if [ -n "${ROS_DOMAIN_ID}" ]; then
CUSTOM_ENVS+=("ROS_DOMAIN_ID=${ROS_DOMAIN_ID}")
Expand Down
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Docker
**/Dockerfile
**/.dockerignore
**/.docker/host
**/.docker/*.bash

# Git
**/.git
Expand All @@ -17,3 +19,7 @@

# Python
**/__pycache__

# Markdown
**/README.md
**/CHANGELOG.md
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,11 @@ RUN if [[ -n "${DOWNLOAD_DATASETS}" ]] ; then \
apt-get install -yq --no-install-recommends \
git-lfs && \
rm -rf /var/lib/apt/lists/* && \
git clone https://gitlab.uni.lu/spacer/phd/AndrejOrsula/assets/textures.git --depth 1 -b master ; \
git clone https://gitlab.uni.lu/spacer/phd/AndrejOrsula/assets/sdf_models.git --depth 1 -b master ; \
exit 0 \
if [[ -n "${UNILU_GITLAB_ACCESS_TOKEN}" ]] ; then \
echo "Downloading default textures and SDF models..." && \
git clone https://gitlab.uni.lu/spacer/phd/AndrejOrsula/assets/textures.git --depth 1 -b master && \
git clone https://gitlab.uni.lu/spacer/phd/AndrejOrsula/assets/sdf_models.git --depth 1 -b master \
; fi \
; else \
echo "Default datasets are disabled. Downloading skipped." \
; fi
Expand Down

0 comments on commit d4923c5

Please sign in to comment.