Skip to content

Commit 9b41aef

Browse files
author
Your Name
committed
refactor: Replace direct Docker commands with utility functions in snow scripts
1 parent c7f886c commit 9b41aef

9 files changed

Lines changed: 701 additions & 759 deletions

File tree

lib-bash/snow/build.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function doSnowBuildImagesLogic() {
44

55
cursorSave
66
_iNote "Pruning Old Images"
7-
$SB_DOCKER_PATH image prune -f --filter "label=org.snowblower.project=$SB_PROJECT_HASH"
7+
runDocker image prune -f --filter "label=org.snowblower.project=$SB_PROJECT_HASH"
88
checkLastCommand "Pruned Old Images" "Prune Failed" 1
99

1010
rm -f "$SB_PROJECT_ROOT/result"
@@ -14,9 +14,9 @@ function doSnowBuildImagesLogic() {
1414
runBuilder bash -c "nix build --impure --out-link "/tmp/result" .#dockerRuntimeImagePackage && cp -rL /tmp/result /snowblower/result"
1515
checkLastCommand "Building Runtime Docker Image" "Build Failed" 1
1616

17-
_iNote "Loading Runtime Docker Image"
1817
cursorSave
19-
$SB_DOCKER_PATH load -i "$SB_PROJECT_ROOT/result"
18+
_iNote "Loading Runtime Docker Image"
19+
runDocker load -i "$SB_PROJECT_ROOT/result"
2020
checkLastCommand "Loading Runtime Docker Image" "Load Failed" 1
2121

2222
rm -f "$SB_PROJECT_ROOT/result"
@@ -28,7 +28,7 @@ function doSnowBuildImagesLogic() {
2828

2929
cursorSave
3030
_iNote "Loading Tooling Docker Image"
31-
$SB_DOCKER_PATH load -i "$SB_PROJECT_ROOT/result"
31+
runDocker load -i "$SB_PROJECT_ROOT/result"
3232
checkLastCommand "Loading Tooling Docker Image" "Load Failed" 1
3333

3434
rm -f "$SB_PROJECT_ROOT/result"
@@ -39,7 +39,7 @@ function doSnowBuildImagesLogic() {
3939
}
4040

4141
function doSnowBuildFilesLogic() {
42-
$SB_NIX_PATH run --impure .#snowblowerFiles -L
42+
runBuilder bash -c "nix run --impure .#snowblowerFiles -L"
4343
return 0
4444
}
4545

lib-bash/snow/command-execute.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function doRoutedCommandExecute() {
3232
_iVerbose "Executing command via docker compose in %s service" $env_type
3333

3434
# Execute the command with proper shell evaluation
35-
$SB_DOCKER_PATH compose -f "$SB_WORKSPACE_ROOT/docker-compose.yml" "${ARGS[@]}" "with-snowblower" "$@"
35+
runDockerCompose "${ARGS[@]}" "with-snowblower" "$@"
3636
return $?
3737
;;
3838
service)
@@ -45,7 +45,7 @@ function doRoutedCommandExecute() {
4545
_iVerbose "Executing command via docker compose run in %s service" "$service_name"
4646

4747
# Execute the command using docker compose run
48-
$SB_DOCKER_PATH compose -f "$SB_WORKSPACE_ROOT/docker-compose.yml" run --rm "$service_name" "$@"
48+
runDockerCompose run --rm "$service_name" "$@"
4949
return $?
5050
;;
5151
*)

lib-bash/snow/down.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function doSnowDownLogic() {
77

88
# If it's running, run docker compose down and wait for it to finish then run doDestroySession
99
_iOk "Stopping SnowBlower services..."
10-
$SB_DOCKER_PATH compose -f "$SB_WORKSPACE_ROOT/docker-compose.yml" --profile auto-start down --remove-orphans
10+
runDockerCompose --profile auto-start down --remove-orphans
1111

1212
_iHeart "SnowBlower has been stopped."
1313
return 0

lib-bash/snow/ps.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function doSnowPsLogic() {
66
return 1
77
fi
88

9-
$SB_DOCKER_PATH -f "$SB_WORKSPACE_ROOT/docker-compose.yml" ps
9+
runDockerCompose ps
1010

1111
return 0
1212
}

lib-bash/snow/switch.sh

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,10 @@ function doSnowSwitch() {
1010
doSnowDownLogic
1111
fi
1212

13-
doSnowBuildLogic
14-
15-
# Start Docker
16-
doSnowUpLogic
13+
doSnowBuildImagesLogic
1714

1815
_iNote "Running file generator..."
19-
doRoutedCommandExecute tools snowblower-files
20-
21-
# Take it back down
22-
doSnowDownLogic
16+
doSnowBuildFilesLogic
2317

2418
_iHeart "Switch Complete"
2519

lib-bash/snow/up.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function doSnowUpLogic() {
99
fi
1010

1111
# Start docker-compose detached
12-
$SB_DOCKER_PATH compose -f "$SB_WORKSPACE_ROOT/docker-compose.yml" --profile auto-start up --detach --remove-orphans "$@"
12+
runDockerCompose --profile auto-start up --detach --remove-orphans "$@"
1313
doRoutedCommandExecute "tools" "snowblower-hooks" "tools_pre"
1414

1515
return 0
@@ -35,7 +35,7 @@ function doSnowUpWithMenu() {
3535
echo "────────────────────────────────────────"
3636

3737
# Show last 20 lines of logs
38-
$SB_DOCKER_PATH compose -f "$SB_WORKSPACE_ROOT/docker-compose.yml" --profile auto-start logs --tail=20 2>/dev/null || echo "No logs available yet..."
38+
runDockerCompose logs --tail=20 2>/dev/null || echo "No logs available yet..."
3939

4040
echo "────────────────────────────────────────"
4141
echo -n "Press 'q' to quit or any other key to refresh: "

lib-bash/snow/update.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function doSnowUpdate {
22

3-
$SB_NIX_PATH flake update
3+
runNix flake update
44
doSnowSwitch
55

66
exit 0

lib-bash/snow/utils.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ function runBuilder() {
66
$SB_DOCKER_PATH compose -f "$SB_WORKSPACE_ROOT/docker-compose.yml" run --build --rm builder "$@"
77
}
88

9-
109
function runDockerCompose() {
1110
$SB_DOCKER_PATH compose -f "$SB_WORKSPACE_ROOT/docker-compose.yml" "$@"
11+
}
12+
13+
function runDocker() {
14+
$SB_DOCKER_PATH "$@"
1215
}

0 commit comments

Comments
 (0)