Skip to content

Commit 9ea24b3

Browse files
committed
Also catch ignored file presence
Was finding that extraneous image rebuilds were happening because ignored files were slipping into the source tree via use in container. This adds extra protections to catch files modified that would impact builds including `./docker/` and poetry files.
1 parent b4b3f1b commit 9ea24b3

6 files changed

+39
-10
lines changed
File renamed without changes.

.dockerignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/.git
22
/.workspace-shell-dev
3-
/docker/.container_xauth
3+
/.container_xauth
44
/HoloLens2-ResearchMode-Unity
55
/unity

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Project Ignores
33
#
44
/.workspace-shell-dev/
5-
/docker/.container_xauth
5+
/.container_xauth
66

77
# This .gitignore file should be placed at the root of your Unity project directory
88
#

angel-docker-build.sh

+32-7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ Options:
1919
"
2020
}
2121

22+
function log()
23+
{
24+
>&2 echo "$@"
25+
}
26+
2227
# Option parsing
2328
dc_forward_params=()
2429
while [[ $# -gt 0 ]]
@@ -29,7 +34,7 @@ do
2934
exit 0
3035
;;
3136
--force)
32-
echo "Forcing build regardless of workspace hygiene."
37+
log "Forcing build regardless of workspace hygiene."
3338
shift
3439
FORCE_BUILD=1
3540
;;
@@ -39,23 +44,43 @@ do
3944
esac
4045
done
4146

42-
git_status="$(git status --porcelain "${SCRIPT_DIR}/ros")"
43-
if [[ -n "$git_status" ]]
47+
# Check if there are modified or "new" files in the workspace.
48+
# NODE: `warn_build_spaces` should be expanded if more things start to become
49+
# part of docker builds. Maybe read this in from somewhere else instead
50+
# of encoding here?
51+
warn_build_spaces=(
52+
"${SCRIPT_DIR}/ros"
53+
"${SCRIPT_DIR}/docker"
54+
"${SCRIPT_DIR}/pyproject.toml"
55+
"${SCRIPT_DIR}/poetry.lock"
56+
)
57+
git_status="$(git status --porcelain "${warn_build_spaces[@]}")"
58+
# Check if there are ignored files in the workspace that should not be there.
59+
git_clean_dr="$(git clean "${warn_build_spaces[@]}" -xdn)"
60+
if [[ -n "${git_status}" ]] || [[ -n "${git_clean_dr}" ]]
4461
then
45-
echo "WARNING: ROS workspace subtree is not clean."
62+
log "WARNING: ROS workspace subtree is modified and/or un-clean."
63+
if [[ -n "${git_status}" ]]
64+
then
65+
log "WARNING: -- There are modified / new files."
66+
fi
67+
if [[ -n "${git_clean_dr}" ]]
68+
then
69+
log "WARNING: -- There are unexpected ignored files (check git clean -xdn)."
70+
fi
4671
if [[ -n "$FORCE_BUILD" ]]
4772
then
48-
echo "WARNING: Force enabled, building anyway."
73+
log "WARNING: Force enabled, building anyway."
4974
else
50-
echo "ERROR: Refusing to build images."
75+
log "ERROR: Refusing to build images."
5176
exit 1
5277
fi
5378
fi
5479

5580
if [[ "${#dc_forward_params[@]}" -gt 0 ]]
5681
then
5782
# shellcheck disable=SC2145
58-
echo "Forwarding to docker-compose: ${dc_forward_params[@]}"
83+
log "Forwarding to docker-compose: ${dc_forward_params[@]}"
5984
fi
6085

6186
docker-compose \

angel-workspace-shell.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ done
7474
SERVICE_NAME="${ARG_SERVICE_NAME:-${DEFAULT_SERVICE_NAME}}"
7575

7676
# Create a permissions file for xauthority.
77-
XAUTH_DIR="${SCRIPT_DIR}/docker/.container_xauth"
77+
XAUTH_DIR="${SCRIPT_DIR}/.container_xauth"
7878
# Exporting to be used in replacement in docker-compose file.
7979
XAUTH_FILEPATH="$(mktemp "${XAUTH_DIR}/local-XXXXXX.xauth")"
8080
export XAUTH_FILEPATH

docker/docker-compose.yml

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ services:
1212
context: .. # repo root
1313
dockerfile: docker/workspace-base-dev/Dockerfile
1414
cache_from:
15+
- ${PTG_REGISTRY}/workspace-base-dev:latest
1516
- ${PTG_REGISTRY}/workspace-base-dev:${PTG_TAG}
1617
profiles:
1718
- build-only
@@ -29,6 +30,7 @@ services:
2930
PTG_REGISTRY: # from .env file
3031
PTG_TAG: # from .env file
3132
cache_from:
33+
- ${PTG_REGISTRY}/workspace-build-dev:latest
3234
- ${PTG_REGISTRY}/workspace-build-dev:${PTG_TAG}
3335
profiles:
3436
- build-only
@@ -47,6 +49,7 @@ services:
4749
tty: true
4850
volumes:
4951
- /dev/shm:/dev/shm
52+
# Host sharing
5053
- ../poetry.lock:/angel_workspace/poetry.lock
5154
- ../pyproject.toml:/angel_workspace/pyproject.toml
5255
- ../ros:/angel_workspace/src
@@ -63,6 +66,7 @@ services:
6366
# assume this file exists, should be created before running.
6467
- ${XAUTH_FILEPATH}:/tmp/.docker.xauth
6568
environment:
69+
PYTHONDONTWRITEBYTECODE: "true"
6670
HISTFILE: /angel_workspace/stuff/bash_history
6771
CYCLONE_DDS_INTERFACE: # from .env file or parent environment
6872
SETUP_WORKSPACE_INSTALL: # from .env file or parent environment

0 commit comments

Comments
 (0)