2929# PREREQUISITES:
3030# 1. Python 3.8+ must be installed
3131# 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
3532#
3633# ENVIRONMENT VARIABLES:
3734# SCANCODE_DB_PASS -> Database password (default: "scancode")
8380DB_NAME = "scancode"
8481D2D_DIR = Path ("d2d" )
8582
83+ def pull_required_images (docker_bin ):
84+ """Ensure the required Docker images are present."""
85+ print ("Checking and pulling required Docker images (if missing)..." )
86+ images = [DB_IMAGE , SCANCODE_IMAGE ]
87+ for image in images :
88+ safe_run ([docker_bin , "pull" , image ], silent = True )
89+ print ("Docker images are ready." )
90+
8691
8792def get_free_port ():
8893 """Find a free host port for Postgres."""
@@ -177,6 +182,9 @@ def main():
177182 print ("Both :from and :to input files are required." , file = sys .stderr )
178183 sys .exit (1 )
179184
185+ docker_bin = shutil .which ("docker" ) or "docker"
186+ pull_required_images (docker_bin )
187+
180188 from_name , to_name = prepare_d2d_dir (file_map ["from" ], file_map ["to" ])
181189
182190 db_container_name = f"scancode_db_{ uuid .uuid4 ().hex [:6 ]} "
@@ -185,7 +193,6 @@ def main():
185193
186194 project_name = f"scanpipe_{ uuid .uuid4 ().hex [:8 ]} "
187195
188- docker_bin = shutil .which ("docker" ) or "docker"
189196
190197 try :
191198 safe_run (
0 commit comments