|
19 | 19 | # |
20 | 20 | # ScanCode.io is a free software code scanning tool from nexB Inc. and others. |
21 | 21 | # 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 | +# ------------------------------------------------------------------------------ |
22 | 68 |
|
23 | 69 | import argparse |
24 | 70 | import os |
|
32 | 78 |
|
33 | 79 | SCANCODE_IMAGE = "ghcr.io/aboutcode-org/scancode.io:latest" |
34 | 80 | DB_IMAGE = "postgres:13" |
35 | | -DB_USER = "scancode" |
| 81 | +DB_USER = os.getenv("SCANCODE_DB_USER", "scancode") |
36 | 82 | DB_PASS = os.getenv("SCANCODE_DB_PASS", "scancode") |
37 | 83 | DB_NAME = "scancode" |
38 | 84 | D2D_DIR = Path("d2d") |
|
0 commit comments