Skip to content

Commit faffdfe

Browse files
committed
fix cache issue
1 parent bb387ed commit faffdfe

File tree

5 files changed

+63
-19
lines changed

5 files changed

+63
-19
lines changed

robot-template/_build/robot-focal-ros1/Dockerfile-locomotion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ USER ${USER_NAME}
3535
ENV RECIPES_TAG=$RECIPES_TAG
3636

3737
# grow - using configurable recipes tag instead of hardcoded defaults
38-
RUN echo 1 && cd ~/xbot2_ws/recipes/multidof_recipes && git pull origin ${RECIPES_TAG}
38+
RUN cd ~/xbot2_ws/recipes/multidof_recipes && git pull origin ${RECIPES_TAG}
3939

4040
WORKDIR /home/${USER_NAME}/xbot2_ws
4141

robot-template/_build/robot-focal-ros1/build.bash

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,12 @@ else
169169
# AUTOMATIC NETRC SECRET HANDLING
170170
# Check if the user has a .netrc file in their home directory
171171
if [ -f "$HOME/.netrc" ]; then
172-
echo "Found .netrc file, exporting content for build secret..."
173-
export NETRC_CONTENT=$(cat "$HOME/.netrc")
172+
#echo "Found .netrc file, exporting content for build secret..."
173+
export NETRC_CONTENT=$(cat "$HOME/.netrc")
174174
else
175175
# If the file doesn't exist, just print a warning.
176176
# The build can continue, but will fail if private repos are needed.
177-
echo "Warning: ~/.netrc not found. Private repository access may fail."
177+
echo "Warning: ~/.netrc not found. Private repository access may fail."
178178
fi
179179

180180
# Run the bake build

robot-template/_build/robot-focal-ros1/docker-bake.hcl

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,28 @@ variable "ROS_VERSION" { default = "ros1" }
1414
variable "ROBOT_PACKAGES" { default = "" }
1515
variable "ADDITIONAL_PACKAGES" { default = "" }
1616
variable "ROBOT_CONFIG_PATH" { default = "~/xbot2_ws/src/robot_config/setup.sh" }
17+
variable "CI" { default = "" } # Will be set by GitHub Actions
18+
variable "GITHUB_ACTIONS" { default = "" } # Also set by GitHub Actions
19+
variable "LOCAL_CACHE_DIR" { default = "/tmp/buildkit-cache" }
1720

21+
function "cache_from" {
22+
params = [scope]
23+
result = CI != "" ? [
24+
"type=gha,scope=${scope}",
25+
"type=local,src=${LOCAL_CACHE_DIR}/${scope}"
26+
] : [
27+
"type=local,src=${LOCAL_CACHE_DIR}/${scope}"
28+
]
29+
}
30+
function "cache_to" {
31+
params = [scope]
32+
result = CI != "" ? [
33+
"type=gha,mode=max,scope=${scope}",
34+
"type=local,dest=${LOCAL_CACHE_DIR}/${scope},mode=max"
35+
] : [
36+
"type=local,dest=${LOCAL_CACHE_DIR}/${scope},mode=max"
37+
]
38+
}
1839
# Function to generate tags for images
1940
function "tag" {
2041
params = [name, suffix]
@@ -49,9 +70,8 @@ target "base" {
4970

5071

5172
# Persist layer cache for base
52-
cache-from = ["type=gha,scope=${ROS_VERSION}-base"]
53-
cache-to = ["type=gha,mode=max,scope=${ROS_VERSION}-base"]
54-
73+
cache-from = cache_from("${ROS_VERSION}-base")
74+
cache-to = cache_to("${ROS_VERSION}-base")
5575

5676
# Disable registry cache for now to avoid errors
5777
# You can enable this later once images exist in registry
@@ -93,8 +113,9 @@ target "xeno" {
93113
}
94114

95115
# Persist layer cache for xeno (kernel-specific)
96-
cache-from = ["type=gha,scope=${ROS_VERSION}-xeno-v${KERNEL_VER}"]
97-
cache-to = ["type=gha,mode=max,scope=${ROS_VERSION}-xeno-v${KERNEL_VER}"]
116+
cache-from = cache_from("${ROS_VERSION}-base")
117+
cache-to = cache_to("${ROS_VERSION}-base")
118+
98119
}
99120

100121
# Locomotion image - depends on base
@@ -128,8 +149,9 @@ target "locomotion" {
128149
base = "target:base"
129150
}
130151
# Persist layer cache for locomotion
131-
cache-from = ["type=gha,scope=${ROS_VERSION}-locomotion"]
132-
cache-to = ["type=gha,mode=max,scope=${ROS_VERSION}-locomotion"]
152+
cache-from = cache_from("${ROS_VERSION}-base")
153+
cache-to = cache_to("${ROS_VERSION}-base")
154+
133155
}
134156

135157
# Additional groups for specific build scenarios

robot-template/_build/robot-noble-ros2/build.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ else
169169
# AUTOMATIC NETRC SECRET HANDLING
170170
# Check if the user has a .netrc file in their home directory
171171
if [ -f "$HOME/.netrc" ]; then
172-
echo "Found .netrc file, exporting content for build secret..."
172+
#echo "Found .netrc file, exporting content for build secret..."
173173
export NETRC_CONTENT=$(cat "$HOME/.netrc")
174174
else
175175
# If the file doesn't exist, just print a warning.

robot-template/_build/robot-noble-ros2/docker-bake.hcl

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,36 @@ variable "RECIPES_TAG" { default = "kyon" }
1313
variable "ROS_VERSION" { default = "ros2" }
1414
variable "ROBOT_PACKAGES" { default = "" }
1515
variable "ADDITIONAL_PACKAGES" { default = "" }
16+
variable "CI" { default = "" } # Will be set by GitHub Actions
17+
variable "GITHUB_ACTIONS" { default = "" } # Also set by GitHub Actions
18+
variable "LOCAL_CACHE_DIR" { default = "/tmp/buildkit-cache" }
19+
20+
1621

1722
# Function to generate tags for images
1823
function "tag" {
1924
params = [name, suffix]
2025
result = ["${DOCKER_REGISTRY}/${BASE_IMAGE_NAME}-${name}${suffix}:${TAGNAME}"]
2126
}
2227

28+
function "cache_from" {
29+
params = [scope]
30+
result = CI != "" ? [
31+
"type=gha,scope=${scope}",
32+
"type=local,src=${LOCAL_CACHE_DIR}/${scope}"
33+
] : [
34+
"type=local,src=${LOCAL_CACHE_DIR}/${scope}"
35+
]
36+
}
37+
function "cache_to" {
38+
params = [scope]
39+
result = CI != "" ? [
40+
"type=gha,mode=max,scope=${scope}",
41+
"type=local,dest=${LOCAL_CACHE_DIR}/${scope},mode=max"
42+
] : [
43+
"type=local,dest=${LOCAL_CACHE_DIR}/${scope},mode=max"
44+
]
45+
}
2346
# Default group - builds all images in the correct order
2447
group "default" {
2548
targets = ["base", "xeno", "sim"]
@@ -49,9 +72,8 @@ target "base" {
4972

5073

5174
# Persist layer cache for base
52-
cache-from = ["type=gha,scope=${ROS_VERSION}-base"]
53-
cache-to = ["type=gha,mode=max,scope=${ROS_VERSION}-base"]
54-
75+
cache-from = cache_from("${ROS_VERSION}-base")
76+
cache-to = cache_to("${ROS_VERSION}-base")
5577

5678
# Disable registry cache for now to avoid errors
5779
# You can enable this later once images exist in registry
@@ -93,8 +115,8 @@ target "xeno" {
93115
}
94116

95117
# Persist layer cache for xeno (kernel-specific)
96-
cache-from = ["type=gha,scope=${ROS_VERSION}-xeno-v${KERNEL_VER}"]
97-
cache-to = ["type=gha,mode=max,scope=${ROS_VERSION}-xeno-v${KERNEL_VER}"]
118+
cache-from = cache_from("${ROS_VERSION}-base")
119+
cache-to = cache_to("${ROS_VERSION}-base")
98120
}
99121

100122
# sim image - depends on base
@@ -128,8 +150,8 @@ target "sim" {
128150
base = "target:base"
129151
}
130152
# Persist layer cache for sim
131-
cache-from = ["type=gha,scope=${ROS_VERSION}-sim"]
132-
cache-to = ["type=gha,mode=max,scope=${ROS_VERSION}-sim"]
153+
cache-from = cache_from("${ROS_VERSION}-base")
154+
cache-to = cache_to("${ROS_VERSION}-base")
133155
}
134156

135157
# Additional groups for specific build scenarios

0 commit comments

Comments
 (0)