refactor: remove vendored binaries and raw assets from repo

This commit is contained in:
2026-06-07 01:06:21 +07:00
parent 3172f56b75
commit 1b19d5443d
7 changed files with 196 additions and 0 deletions

12
.gitignore vendored
View File

@@ -4,6 +4,11 @@ config.yaml
# ISO output files
*.iso
# Vendored/runtime assets fetched outside git
dcmtk-bin/
legacy/raw/
.local/
# Temp directories
/tmp/dicomdir_*
@@ -20,3 +25,10 @@ Thumbs.db
# Local-only docs tell @VArtzy<farrelnikoson@gmail.com> for request
docs/phases
# Keep placeholder docs for ignored asset directories
!dcmtk-bin/
!dcmtk-bin/README.md
!legacy/
!legacy/raw/
!legacy/raw/README.md

View File

@@ -25,6 +25,9 @@ The service needs:
- MicroDicom files
- writable temp storage
Large runtime assets are intentionally not stored in git.
Use the setup scripts in `scripts/` to stage local copies in ignored directories.
## Setup
Before running the service, make sure the VM has:
- Go installed, if you are building on that machine
@@ -33,6 +36,13 @@ Before running the service, make sure the VM has:
- network access to PACS, the patient API, and the CD publisher
- a writable temp directory
Stage local runtime assets if needed:
```bash
scripts/setup-dcmtk.sh --source-dir /path/to/dcmtk/bin
scripts/setup-microdicom.sh --source-dir /path/to/microdicom
```
Create a local config file from the template:
```bash
@@ -40,6 +50,7 @@ cp config.example.yaml config.yaml
```
Then adjust the paths, hosts, ports, and tokens for your environment.
For local staging via the setup scripts, point config at `.local/dcmtk-bin/` and `.local/microdicom/`.
## Build
A normal Go build is enough in a friendly environment:

View File

@@ -29,6 +29,13 @@ The service needs:
- a writable temp directory
- a free port range for `storescp`
If you do not manage these assets globally on the VM, you can stage them locally first:
```bash
scripts/setup-dcmtk.sh --source-dir /path/to/dcmtk/bin --install-dir /opt/dicom-iso/dcmtk-bin
scripts/setup-microdicom.sh --source-dir /path/to/microdicom --install-dir /opt/dicom-iso/microdicom
```
## Build note
The build environment cannot depend on public internet access.
That means the binary must be built through an approved offline-friendly path.

18
docs/repo-size-cleanup.md Normal file
View File

@@ -0,0 +1,18 @@
# Repo size cleanup
Implemented in the working tree:
- removed tracked binaries from `dcmtk-bin/`
- removed tracked raw assets from `legacy/raw/`
- added `.gitignore` protections
- added setup scripts for DCMTK and MicroDicom
## Finish the cleanup in git history
Rewriting history is still required to shrink the remote repository size.
```bash
git filter-repo --path dcmtk-bin --path legacy/raw --invert-paths
git push --force --all
git push --force --tags
```
Coordinate this with any collaborators first.

14
scripts/purge-git-history.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail
cat <<'EOF'
This rewrites git history to remove large vendored assets.
Run only after committing the current tree cleanup and coordinating with collaborators.
Commands:
git filter-repo --path dcmtk-bin --path legacy/raw --invert-paths
git push --force --all
git push --force --tags
Afterward, collaborators should reclone or hard-reset to the rewritten history.
EOF

76
scripts/setup-dcmtk.sh Executable file
View File

@@ -0,0 +1,76 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
INSTALL_DIR="${INSTALL_DIR:-$ROOT_DIR/.local/dcmtk-bin}"
REQUIRED_BINS=(storescp movescu storescu findscu dcmdump dcmodify getscu echoscu dcmj2pnm)
usage() {
cat <<'EOF'
Usage:
scripts/setup-dcmtk.sh [--source-dir DIR] [--install-dir DIR]
Behavior:
- Copies required DCMTK binaries into a local ignored directory.
- If --source-dir is omitted, binaries are resolved from PATH.
Examples:
scripts/setup-dcmtk.sh --source-dir /opt/dcmtk/bin
scripts/setup-dcmtk.sh --install-dir /data/dcmtk-bin
EOF
}
SOURCE_DIR=""
while [[ $# -gt 0 ]]; do
case "$1" in
--source-dir)
SOURCE_DIR="${2:?missing value for --source-dir}"
shift 2
;;
--install-dir)
INSTALL_DIR="${2:?missing value for --install-dir}"
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 1
;;
esac
done
mkdir -p "$INSTALL_DIR"
resolve_bin() {
local name="$1"
if [[ -n "$SOURCE_DIR" ]]; then
local candidate="$SOURCE_DIR/$name"
[[ -x "$candidate" ]] || { echo "missing executable: $candidate" >&2; return 1; }
printf '%s\n' "$candidate"
return 0
fi
command -v "$name" >/dev/null 2>&1 || { echo "binary not found in PATH: $name" >&2; return 1; }
command -v "$name"
}
for bin in "${REQUIRED_BINS[@]}"; do
src="$(resolve_bin "$bin")"
install -m 0755 "$src" "$INSTALL_DIR/$bin"
echo "installed $bin -> $INSTALL_DIR/$bin"
done
cat <<EOF
Done.
Set these config values:
dcmtk:
storescp: "$INSTALL_DIR/storescp"
movescu: "$INSTALL_DIR/movescu"
storescu: "$INSTALL_DIR/storescu"
EOF

58
scripts/setup-microdicom.sh Executable file
View File

@@ -0,0 +1,58 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
INSTALL_DIR="${INSTALL_DIR:-$ROOT_DIR/.local/microdicom}"
usage() {
cat <<'EOF'
Usage:
scripts/setup-microdicom.sh --source-dir DIR [--install-dir DIR]
Behavior:
- Copies a prepared MicroDicom directory into a local ignored directory.
- Expected source contents include files like AUTORUN.INF, RUN.BAT, and MICROD/.
EOF
}
SOURCE_DIR=""
while [[ $# -gt 0 ]]; do
case "$1" in
--source-dir)
SOURCE_DIR="${2:?missing value for --source-dir}"
shift 2
;;
--install-dir)
INSTALL_DIR="${2:?missing value for --install-dir}"
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 1
;;
esac
done
[[ -n "$SOURCE_DIR" ]] || { echo "--source-dir is required" >&2; exit 1; }
[[ -d "$SOURCE_DIR" ]] || { echo "source directory does not exist: $SOURCE_DIR" >&2; exit 1; }
[[ -f "$SOURCE_DIR/AUTORUN.INF" ]] || { echo "missing AUTORUN.INF in source directory" >&2; exit 1; }
[[ -d "$SOURCE_DIR/MICROD" ]] || { echo "missing MICROD/ in source directory" >&2; exit 1; }
rm -rf "$INSTALL_DIR"
mkdir -p "$INSTALL_DIR"
cp -a "$SOURCE_DIR"/. "$INSTALL_DIR"/
echo "installed MicroDicom assets -> $INSTALL_DIR"
cat <<EOF
Done.
Set this config value:
iso:
microdicom_path: "$INSTALL_DIR"
EOF