diff --git a/docker/.container_xauth/.placeholder b/.container_xauth/.placeholder similarity index 100% rename from docker/.container_xauth/.placeholder rename to .container_xauth/.placeholder diff --git a/.dockerignore b/.dockerignore index d6d2c923b..79ee34010 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,5 @@ /.git /.workspace-shell-dev -/docker/.container_xauth +/.container_xauth /HoloLens2-ResearchMode-Unity /unity diff --git a/.gitignore b/.gitignore index ab9c8cd69..d309d669f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ # Project Ignores # /.workspace-shell-dev/ -/docker/.container_xauth +/.container_xauth # This .gitignore file should be placed at the root of your Unity project directory # diff --git a/angel-docker-build.sh b/angel-docker-build.sh index 9810f480d..706f41e3d 100755 --- a/angel-docker-build.sh +++ b/angel-docker-build.sh @@ -19,6 +19,11 @@ Options: " } +function log() +{ + >&2 echo "$@" +} + # Option parsing dc_forward_params=() while [[ $# -gt 0 ]] @@ -29,7 +34,7 @@ do exit 0 ;; --force) - echo "Forcing build regardless of workspace hygiene." + log "Forcing build regardless of workspace hygiene." shift FORCE_BUILD=1 ;; @@ -39,15 +44,35 @@ do esac done -git_status="$(git status --porcelain "${SCRIPT_DIR}/ros")" -if [[ -n "$git_status" ]] +# Check if there are modified or "new" files in the workspace. +# NODE: `warn_build_spaces` should be expanded if more things start to become +# part of docker builds. Maybe read this in from somewhere else instead +# of encoding here? +warn_build_spaces=( + "${SCRIPT_DIR}/ros" + "${SCRIPT_DIR}/docker" + "${SCRIPT_DIR}/pyproject.toml" + "${SCRIPT_DIR}/poetry.lock" +) +git_status="$(git status --porcelain "${warn_build_spaces[@]}")" +# Check if there are ignored files in the workspace that should not be there. +git_clean_dr="$(git clean "${warn_build_spaces[@]}" -xdn)" +if [[ -n "${git_status}" ]] || [[ -n "${git_clean_dr}" ]] then - echo "WARNING: ROS workspace subtree is not clean." + log "WARNING: ROS workspace subtree is modified and/or un-clean." + if [[ -n "${git_status}" ]] + then + log "WARNING: -- There are modified / new files." + fi + if [[ -n "${git_clean_dr}" ]] + then + log "WARNING: -- There are unexpected ignored files (check git clean -xdn)." + fi if [[ -n "$FORCE_BUILD" ]] then - echo "WARNING: Force enabled, building anyway." + log "WARNING: Force enabled, building anyway." else - echo "ERROR: Refusing to build images." + log "ERROR: Refusing to build images." exit 1 fi fi @@ -55,7 +80,7 @@ fi if [[ "${#dc_forward_params[@]}" -gt 0 ]] then # shellcheck disable=SC2145 - echo "Forwarding to docker-compose: ${dc_forward_params[@]}" + log "Forwarding to docker-compose: ${dc_forward_params[@]}" fi docker-compose \ diff --git a/angel-workspace-shell.sh b/angel-workspace-shell.sh index 8cdb03f0c..44eb90734 100755 --- a/angel-workspace-shell.sh +++ b/angel-workspace-shell.sh @@ -74,7 +74,7 @@ done SERVICE_NAME="${ARG_SERVICE_NAME:-${DEFAULT_SERVICE_NAME}}" # Create a permissions file for xauthority. -XAUTH_DIR="${SCRIPT_DIR}/docker/.container_xauth" +XAUTH_DIR="${SCRIPT_DIR}/.container_xauth" # Exporting to be used in replacement in docker-compose file. XAUTH_FILEPATH="$(mktemp "${XAUTH_DIR}/local-XXXXXX.xauth")" export XAUTH_FILEPATH diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index e80e51393..cef1d19b9 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -12,6 +12,7 @@ services: context: .. # repo root dockerfile: docker/workspace-base-dev/Dockerfile cache_from: + - ${PTG_REGISTRY}/workspace-base-dev:latest - ${PTG_REGISTRY}/workspace-base-dev:${PTG_TAG} profiles: - build-only @@ -29,6 +30,7 @@ services: PTG_REGISTRY: # from .env file PTG_TAG: # from .env file cache_from: + - ${PTG_REGISTRY}/workspace-build-dev:latest - ${PTG_REGISTRY}/workspace-build-dev:${PTG_TAG} profiles: - build-only @@ -47,6 +49,7 @@ services: tty: true volumes: - /dev/shm:/dev/shm + # Host sharing - ../poetry.lock:/angel_workspace/poetry.lock - ../pyproject.toml:/angel_workspace/pyproject.toml - ../ros:/angel_workspace/src @@ -63,6 +66,7 @@ services: # assume this file exists, should be created before running. - ${XAUTH_FILEPATH}:/tmp/.docker.xauth environment: + PYTHONDONTWRITEBYTECODE: "true" HISTFILE: /angel_workspace/stuff/bash_history CYCLONE_DDS_INTERFACE: # from .env file or parent environment SETUP_WORKSPACE_INSTALL: # from .env file or parent environment