@echo off REM ============================================================ REM sec_fsnds - Local Docker setup REM ============================================================ REM This script: REM 1. Asks the user for the values that differ per-host REM (sa password, port, data dir, container name, edition) REM 2. Writes a .env file that docker compose will read REM 3. Downloads Dockerfile + docker-compose.yaml from Hugging Face REM 4. Downloads the 4-part 7z archive (~40 GB total) from HF REM 5. Extracts sec_fsnds.mdf + sec_fsnds_log.ldf into the data dir REM REM Requires: curl (built in on Windows 10 1803+), Docker Desktop, REM and 7-Zip (7z.exe) on PATH or at the default install path REM ============================================================ setlocal EnableDelayedExpansion echo. echo ============================================================ echo sec_fsnds local setup echo ============================================================ echo. REM ------------------------------------------------------------- REM Hugging Face URLs REM ------------------------------------------------------------- set "HF_REPO=https://huggingface.co/datasets/DenyTranDFW/SEC-Financial-Statements-And-Notes-Dataset/resolve/main" set "HF_DOCKERFILE=%HF_REPO%/Dockerfile" set "HF_COMPOSE=%HF_REPO%/docker-compose.yaml" set "HF_VOL1=%HF_REPO%/archive/sec_fsnds_db_4vol.7z.001" set "HF_VOL2=%HF_REPO%/archive/sec_fsnds_db_4vol.7z.002" set "HF_VOL3=%HF_REPO%/archive/sec_fsnds_db_4vol.7z.003" set "HF_VOL4=%HF_REPO%/archive/sec_fsnds_db_4vol.7z.004" REM ------------------------------------------------------------- REM Sanity checks: curl and 7z must be available REM ------------------------------------------------------------- where curl >nul 2>nul if errorlevel 1 ( echo ERROR: curl.exe was not found on PATH. echo curl ships with Windows 10 1803 and later. exit /b 1 ) set "SEVENZIP=" where 7z >nul 2>nul if not errorlevel 1 ( set "SEVENZIP=7z" ) else if exist "C:\Program Files\7-Zip\7z.exe" ( set "SEVENZIP=C:\Program Files\7-Zip\7z.exe" ) else ( echo ERROR: 7-Zip (7z.exe) was not found on PATH or at echo C:\Program Files\7-Zip\7z.exe echo Download from https://www.7-zip.org and install before echo running this script. exit /b 1 ) echo Found 7-Zip: !SEVENZIP! REM ------------------------------------------------------------- REM Prompts REM ------------------------------------------------------------- echo. echo You will be asked a few questions. Press Enter to accept the echo value shown in [brackets]. echo. set "SA_PASSWORD=" :ask_password set /p "SA_PASSWORD=SQL Server 'sa' password (WARNING - visible as you type): " if "!SA_PASSWORD!"=="" ( echo Password cannot be empty. goto ask_password ) set "HOST_PORT=1434" set /p "HOST_PORT=Host port to expose SQL Server on [1434]: " set "CONTAINER_NAME=mssql-sec-fsnds" set /p "CONTAINER_NAME=Docker container name [mssql-sec-fsnds]: " set "HOST_DATA_DIR=%CD%\data" set /p "HOST_DATA_DIR=Host directory for database files [%CD%\data]: " set "MSSQL_PID=Developer" set /p "MSSQL_PID=SQL Server edition (Developer/Express/Standard/Enterprise) [Developer]: " echo. echo --- Summary --- echo sa password : (hidden) echo host port : !HOST_PORT! echo container : !CONTAINER_NAME! echo data dir : !HOST_DATA_DIR! echo edition : !MSSQL_PID! echo. set "CONFIRM=Y" set /p "CONFIRM=Proceed with these values? [Y/n]: " if /i "!CONFIRM!"=="N" ( echo Aborted by user. exit /b 1 ) REM ------------------------------------------------------------- REM Write .env REM ------------------------------------------------------------- echo. echo --- Writing .env --- ( echo # Generated by sec_fsnds_setup.cmd - do not commit this file echo ACCEPT_EULA=Y echo MSSQL_SA_PASSWORD=!SA_PASSWORD! echo MSSQL_PID=!MSSQL_PID! echo HOST_PORT=!HOST_PORT! echo CONTAINER_NAME=!CONTAINER_NAME! echo HOST_DATA_DIR=!HOST_DATA_DIR! ) > .env if errorlevel 1 ( echo ERROR: could not write .env exit /b 1 ) echo Wrote .env REM ------------------------------------------------------------- REM Create data directory REM ------------------------------------------------------------- if not exist "!HOST_DATA_DIR!" ( echo --- Creating data directory !HOST_DATA_DIR! --- mkdir "!HOST_DATA_DIR!" if errorlevel 1 ( echo ERROR: could not create !HOST_DATA_DIR! exit /b 1 ) ) REM ------------------------------------------------------------- REM Download Dockerfile + compose REM ------------------------------------------------------------- echo. echo --- Downloading Dockerfile --- curl -L --fail --retry 3 -C - -o "Dockerfile" "%HF_DOCKERFILE%" if errorlevel 1 ( echo ERROR: Dockerfile download failed. exit /b 1 ) echo. echo --- Downloading docker-compose.yaml --- curl -L --fail --retry 3 -C - -o "docker-compose.yaml" "%HF_COMPOSE%" if errorlevel 1 ( echo ERROR: docker-compose.yaml download failed. exit /b 1 ) REM ------------------------------------------------------------- REM Download database archive volumes (~10 GB each, ~40 GB total) REM curl -C - enables resume if a download is interrupted. REM ------------------------------------------------------------- echo. echo --- Downloading database archive (4 volumes, ~40 GB total) --- echo This will take a while. If interrupted, re-run the script echo and curl will resume where it left off. echo. for %%V in (001 002 003 004) do ( echo --- Downloading sec_fsnds_db_4vol.7z.%%V --- curl -L --fail --retry 5 -C - -o "!HOST_DATA_DIR!\sec_fsnds_db_4vol.7z.%%V" "!HF_REPO!/archive/sec_fsnds_db_4vol.7z.%%V" if errorlevel 1 ( echo ERROR: sec_fsnds_db_4vol.7z.%%V download failed. echo Re-run this script to resume. exit /b 1 ) ) REM ------------------------------------------------------------- REM Extract the archive REM ------------------------------------------------------------- echo. echo --- Extracting database files (293 GB, may take 10-20 min) --- "!SEVENZIP!" x -o"!HOST_DATA_DIR!" "!HOST_DATA_DIR!\sec_fsnds_db_4vol.7z.001" -y if errorlevel 1 ( echo ERROR: 7z extraction failed. exit /b 1 ) echo Extraction complete. REM Verify the extracted files exist if not exist "!HOST_DATA_DIR!\sec_fsnds.mdf" ( echo ERROR: sec_fsnds.mdf not found after extraction. exit /b 1 ) if not exist "!HOST_DATA_DIR!\sec_fsnds_log.ldf" ( echo ERROR: sec_fsnds_log.ldf not found after extraction. exit /b 1 ) echo Verified: sec_fsnds.mdf and sec_fsnds_log.ldf present. echo. echo ============================================================ echo Setup complete echo ============================================================ echo. echo Next steps: echo. echo 1. Build and start the container: echo docker compose up -d --build echo. echo 2. Watch the logs until "SQL Server is now ready": echo docker compose logs -f echo. echo 3. Connect: echo Server : localhost,!HOST_PORT! echo User : sa echo Password : (what you entered) echo Database : sec_fsnds echo. echo 4. (Optional) Install stored procedures: echo Download the sql/ folder from the Hugging Face repo echo and run each .sql file with sqlcmd -i echo. echo Your .env file holds the values above. Keep it out of source echo control -- it contains the sa password in plaintext. echo. echo You can safely delete the .7z archive volumes from !HOST_DATA_DIR! echo after verifying the database starts correctly. echo. endlocal