Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
8661c024
Unverified
Commit
8661c024
authored
Apr 10, 2025
by
wineandchord
Committed by
GitHub
Apr 10, 2025
Browse files
[CI] Add auto update workflow for Dockerfile graph (#11879)
Signed-off-by:
wineandchord
<
guoqizhou19@gmail.com
>
parent
ce8d6b75
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
0 deletions
+84
-0
.pre-commit-config.yaml
.pre-commit-config.yaml
+6
-0
tools/update-dockerfile-graph.sh
tools/update-dockerfile-graph.sh
+78
-0
No files found.
.pre-commit-config.yaml
View file @
8661c024
...
...
@@ -122,6 +122,12 @@ repos:
language
:
system
always_run
:
true
pass_filenames
:
false
-
id
:
update-dockerfile-graph
name
:
Update Dockerfile dependency graph
entry
:
tools/update-dockerfile-graph.sh
language
:
script
files
:
^docker/Dockerfile$
pass_filenames
:
false
# Keep `suggestion` last
-
id
:
suggestion
name
:
Suggestion
...
...
tools/update-dockerfile-graph.sh
0 → 100755
View file @
8661c024
#!/bin/bash
# Update Dockerfile dependency graph when docker/Dockerfile changes.
# This script is designed to be used as a pre-commit hook.
set
-euo
pipefail
# Check if docker/Dockerfile is staged for commit
if
git diff
--cached
--name-only
|
grep
-q
"^docker/Dockerfile$"
;
then
echo
"docker/Dockerfile has changed, attempting to update dependency graph..."
# Check if Docker is installed and running
if
!
command
-v
docker &> /dev/null
;
then
echo
"Warning: Docker command not found. Skipping Dockerfile graph update."
echo
"Please install Docker to automatically update the graph: https://docs.docker.com/get-docker/"
exit
0
fi
if
!
docker info &> /dev/null
;
then
echo
"Warning: Docker daemon is not running. Skipping Dockerfile graph update."
echo
"Please start Docker to automatically update the graph."
exit
0
fi
# Define the target file path
TARGET_GRAPH_FILE
=
"docs/source/assets/contributing/dockerfile-stages-dependency.png"
# Ensure target directory exists
mkdir
-p
"
$(
dirname
"
$TARGET_GRAPH_FILE
"
)
"
# Store old image hash in a variable if the file exists
OLD_HASH
=
""
if
[
-f
"
$TARGET_GRAPH_FILE
"
]
;
then
OLD_HASH
=
$(
sha256sum
"
$TARGET_GRAPH_FILE
"
)
fi
# Generate Dockerfile graph
echo
"Running dockerfilegraph tool..."
docker run
\
--rm
\
--user
"
$(
id
-u
)
:
$(
id
-g
)
"
\
--workdir
/workspace
\
--volume
"
$(
pwd
)
"
:/workspace
\
ghcr.io/patrickhoefler/dockerfilegraph:alpine
\
--output
png
\
--dpi
200
\
--max-label-length
50
\
--filename
docker/Dockerfile
\
--legend
echo
"Finding generated PNG file..."
# Check for Dockerfile.png in the root directory (most likely location)
if
[
-f
"./Dockerfile.png"
]
;
then
echo
"Found generated file at: ./Dockerfile.png"
mv
"./Dockerfile.png"
"
$TARGET_GRAPH_FILE
"
else
# Try to find it elsewhere
DOCKERFILE_PNG
=
$(
find
.
-name
"Dockerfile.png"
-type
f |
head
-1
)
if
[
-n
"
$DOCKERFILE_PNG
"
]
;
then
echo
"Found generated file at:
$DOCKERFILE_PNG
"
mv
"
$DOCKERFILE_PNG
"
"
$TARGET_GRAPH_FILE
"
else
echo
"Error: Could not find the generated PNG file"
find
.
-name
"*.png"
-type
f
-mmin
-5
exit
1
fi
fi
# Check if the graph has changed
NEW_HASH
=
$(
sha256sum
"
$TARGET_GRAPH_FILE
"
)
if
[
"
$NEW_HASH
"
!=
"
$OLD_HASH
"
]
;
then
echo
"Graph has changed. Please stage the updated file:
$TARGET_GRAPH_FILE
"
exit
1
else
echo
"No changes in graph detected."
fi
fi
exit
0
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment