Skip to content

feat: improve docker cleanup helper#797

Merged
exKAZUu merged 3 commits into
mainfrom
feat/improve-docker-helper-scripts
May 20, 2026
Merged

feat: improve docker cleanup helper#797
exKAZUu merged 3 commits into
mainfrom
feat/improve-docker-helper-scripts

Conversation

@exKAZUu
Copy link
Copy Markdown
Member

@exKAZUu exKAZUu commented May 20, 2026

Summary

  • add cleanup.sh as the Docker helper cleanup entry point
  • make cleanup.sh remove apt artifacts and the copied ./bash helper directory by default
  • remove the old cleanup-apt.sh helper so downstream Dockerfiles use the broader cleanup name

Why

  • review feedback on downstream Dockerfiles showed that copied helper scripts should be removed by the generated cleanup helper where possible
  • the old cleanup-apt.sh name no longer fits when cleanup also owns helper-script removal
  • wb optimizeForDockerBuild --outside generates these helper files together, so downstreams can migrate directly to cleanup.sh

Testing

  • bash -n packages/wb/docker/bash/cleanup.sh
  • yarn workspace @willbooster/wb start --working-dir /tmp/wb-cleanup-script-check optimizeForDockerBuild --outside
  • confirmed /tmp/wb-cleanup-script-check/dist/bash includes cleanup.sh
  • yarn verify

Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new cleanup.sh script and updates cleanup-apt.sh to delegate to it when available, while maintaining standalone functionality for backward compatibility. The review feedback highlights an opportunity to reduce code redundancy between the two scripts and suggests adding documentation to clarify the safety check that conditionally deletes the script directory.

Comment thread packages/wb/docker/bash/cleanup-apt.sh Outdated
Comment on lines +12 to +15
apt-get purge -qq -y curl wget || true
apt-get autoremove -qq -y
apt-get clean -qq
rm -rf /var/lib/apt/lists/*
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The apt cleanup logic is duplicated here and in cleanup.sh. According to the repository style guide (Rule 6), code should be simplified to eliminate redundancy. While this duplication allows cleanup-apt.sh to function as a standalone script for backward compatibility (e.g., if only this script is copied into a Docker image), it increases the maintenance burden if the cleanup steps need to change in the future.

References
  1. Simplify code as much as possible to eliminate redundancy. (link)

apt-get clean -qq
rm -rf /var/lib/apt/lists/*

if [ -z "${WB_KEEP_DOCKER_SCRIPTS:-}" ] && [ "$(basename "${SCRIPT_DIR}")" = "bash" ]; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The check [ "$(basename "${SCRIPT_DIR}")" = "bash" ] acts as a safety guard but relies on a hardcoded directory name. According to the repository style guide (Rule 13), complex or non-obvious logic should be documented. It would be beneficial to add a comment explaining that this check prevents accidental deletion of parent directories if the script is executed from an unexpected location. Additionally, consider if checking for the presence of other helper scripts (e.g., cleanup-apt.sh) would provide a more robust identification of the target directory.

Suggested change
if [ -z "${WB_KEEP_DOCKER_SCRIPTS:-}" ] && [ "$(basename "${SCRIPT_DIR}")" = "bash" ]; then
# Only remove the directory if it's named "bash" to avoid accidental deletion of system directories
if [ -z "${WB_KEEP_DOCKER_SCRIPTS:-}" ] && [ "$(basename "${SCRIPT_DIR}")" = "bash" ]; then
References
  1. Write comments and JSDoc for complex or hard-to-understand code. Explain 'why' in comments. (link)

exKAZUu and others added 2 commits May 20, 2026 20:20
Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
@exKAZUu exKAZUu merged commit 995a6dc into main May 20, 2026
2 checks passed
@exKAZUu exKAZUu deleted the feat/improve-docker-helper-scripts branch May 20, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant