Skip to content

Commit ed706be

Browse files
Merge pull request #3323 from AI-Hypercomputer:igorts/maxtext_venv
PiperOrigin-RevId: 879899638
2 parents 4a37a3b + 0decd18 commit ed706be

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.git
2+
maxtext_venv

dependencies/scripts/docker_upload_runner.sh

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,30 @@ if [[ ! -v CLOUD_IMAGE_NAME ]]; then
5656
exit 1
5757
fi
5858

59-
# Check for dangling symbolic links (target does not exist).
60-
DANGLING_LINKS=$(find -L . -type l)
59+
# In the following sections we will want to check that the files that we are
60+
# packaging in the Docker image don't have outside symbolic links.
61+
# However, we want to exclude files and dirs listed in `.dockerignore` from this check
62+
63+
# Build find exclusion arguments
64+
EXCLUDE_PATHS=()
65+
if [ -f .dockerignore ]; then
66+
while IFS= read -r pattern; do
67+
# Ignore empty lines and comments
68+
if [[ -n "$pattern" && ! "$pattern" =~ ^# ]]; then
69+
EXCLUDE_PATHS+=(-o -path "./$pattern")
70+
fi
71+
done < .dockerignore
72+
fi
73+
74+
PRUNE_ARGS=()
75+
if [ ${#EXCLUDE_PATHS[@]} -gt 0 ]; then
76+
# Remove leading -o and create the prune expression for find
77+
# This tells find not to descend into these paths.
78+
PRUNE_ARGS=(\( "${EXCLUDE_PATHS[@]:1}" \) -prune -o)
79+
fi
80+
81+
# Check for dangling symbolic links (target does not exist), excluding .dockerignore paths.
82+
DANGLING_LINKS=$(find -L . "${PRUNE_ARGS[@]}" -type l -print)
6183
if [ -n "$DANGLING_LINKS" ]; then
6284
echo "ERROR: Found dangling symbolic links in the build context:"
6385
echo "$DANGLING_LINKS"
@@ -67,7 +89,7 @@ if [ -n "$DANGLING_LINKS" ]; then
6789
fi
6890

6991
# Check for absolute symbolic links, which Docker can't follow outside the build context.
70-
ABSOLUTE_LINKS=$(find . -type l -lname '/*')
92+
ABSOLUTE_LINKS=$(find . "${PRUNE_ARGS[@]}" -type l -lname '/*' -print)
7193
if [ -n "$ABSOLUTE_LINKS" ]; then
7294
echo "ERROR: Found symbolic links with absolute paths in the build context:"
7395
echo "$ABSOLUTE_LINKS"

0 commit comments

Comments
 (0)