Skip to content

Commit 520c7db

Browse files
committed
Add documentation for D2D script
Signed-off-by: Tushar Goel <[email protected]>
1 parent 28c40ea commit 520c7db

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

etc/scripts/run_d2d_scio.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,52 @@
1919
#
2020
# ScanCode.io is a free software code scanning tool from nexB Inc. and others.
2121
# Visit https://github.com/aboutcode-org/scancode.io for support and download.
22+
#
23+
# ------------------------------------------------------------------------------
24+
# Documentation: Run ScanCode.io pipelines in Docker (D2D Runner)
25+
# ------------------------------------------------------------------------------
26+
# This script helps execute ScanCode.io pipelines in isolated Docker containers,
27+
# using a local Postgres database and a working directory named `./d2d`.
28+
#
29+
# PREREQUISITES:
30+
# 1. Python 3.8+ must be installed
31+
# 2. Docker must be installed and accessible via `sudo` or user group
32+
# 3. Required Docker images:
33+
# docker pull postgres:13
34+
# docker pull ghcr.io/aboutcode-org/scancode.io:latest
35+
#
36+
# ENVIRONMENT VARIABLES:
37+
# SCANCODE_DB_PASS -> Database password (default: "scancode")
38+
# SCANCODE_DB_USER -> Database user (default: "scancode")
39+
#
40+
# USAGE EXAMPLE:
41+
# sudo su -
42+
# python3 etc/scripts/run_d2d_scio.py \
43+
# --input-file ./path/from/from-intbitset.tar.gz:from \
44+
# --input-file ./path/to/to-intbitset.whl:to \
45+
# --option Python \
46+
# --output res1.json
47+
#
48+
# PARAMETERS:
49+
# --input-file <path:tag> -> Required twice: one tagged `:from`, one tagged `:to`
50+
# --option <name> -> Optional; e.g. Python, Java, Javascript, Scala, Kotlin
51+
# --output <file.json> -> Required; JSON output file for results
52+
#
53+
# INTERNAL STEPS:
54+
# 1. Creates/uses `./d2d` directory
55+
# 2. Copies `from` and `to` files into it
56+
# 3. Spins up a temporary Postgres 13 container
57+
# 4. Waits for DB readiness
58+
# 5. Runs ScanCode.io pipeline (map_deploy_to_develop)
59+
# 6. Saves pipeline output to provided JSON file
60+
# 7. Cleans up containers automatically
61+
#
62+
# CLEANUP:
63+
# Containers are auto-removed, but verify using:
64+
# docker ps -a | grep scancode
65+
# Manual cleanup if needed:
66+
# docker rm -f <container_id>
67+
# ------------------------------------------------------------------------------
2268

2369
import argparse
2470
import os
@@ -32,7 +78,7 @@
3278

3379
SCANCODE_IMAGE = "ghcr.io/aboutcode-org/scancode.io:latest"
3480
DB_IMAGE = "postgres:13"
35-
DB_USER = "scancode"
81+
DB_USER = os.getenv("SCANCODE_DB_USER", "scancode")
3682
DB_PASS = os.getenv("SCANCODE_DB_PASS", "scancode")
3783
DB_NAME = "scancode"
3884
D2D_DIR = Path("d2d")

0 commit comments

Comments
 (0)