69 lines
1.9 KiB
Batchfile
69 lines
1.9 KiB
Batchfile
@echo off
|
|
setlocal EnableExtensions EnableDelayedExpansion
|
|
|
|
set "ROOT_DIR=%~dp0"
|
|
set "ENV_FILE=%ROOT_DIR%\.production.env"
|
|
set "COMPOSE_FILE=%ROOT_DIR%\production.compose.yml"
|
|
set "ARCHIVE_FILE=%ROOT_DIR%\images\webstore-production-images.tar"
|
|
|
|
set "API_IMAGE=webstore-api:prod"
|
|
|
|
echo [1/7] Checking Docker + Compose...
|
|
docker --version >nul 2>&1
|
|
if errorlevel 1 (
|
|
echo ERROR: Docker CLI is not available.
|
|
exit /b 1
|
|
)
|
|
docker compose version >nul 2>&1
|
|
if errorlevel 1 (
|
|
echo ERROR: Docker Compose plugin is not available.
|
|
exit /b 1
|
|
)
|
|
|
|
echo [2/7] Validating required files...
|
|
if not exist "%ENV_FILE%" (
|
|
echo ERROR: Missing env file: "%ENV_FILE%"
|
|
exit /b 1
|
|
)
|
|
if not exist "%COMPOSE_FILE%" (
|
|
echo ERROR: Missing compose file: "%COMPOSE_FILE%"
|
|
exit /b 1
|
|
)
|
|
|
|
echo [3/7] Loading prebuilt image archive if present...
|
|
if exist "%ARCHIVE_FILE%" (
|
|
docker load -i "%ARCHIVE_FILE%"
|
|
if errorlevel 1 (
|
|
echo ERROR: Failed to load image archive.
|
|
exit /b 1
|
|
)
|
|
) else (
|
|
echo WARN: "%ARCHIVE_FILE%" not found. Assuming images already exist locally.
|
|
)
|
|
|
|
echo [4/7] Ensuring API image exists locally...
|
|
docker image inspect "%API_IMAGE%" >nul 2>&1
|
|
if errorlevel 1 (
|
|
echo ERROR: API image "%API_IMAGE%" not found.
|
|
echo Run scripts\build-production-images.bat first or provide the archive in images\.
|
|
exit /b 1
|
|
)
|
|
|
|
echo [5/7] Starting production stack for students...
|
|
pushd "%ROOT_DIR%" >nul
|
|
docker compose --env-file .production.env -f production.compose.yml up -d
|
|
if errorlevel 1 (
|
|
popd >nul
|
|
echo ERROR: Failed to start compose stack.
|
|
exit /b 1
|
|
)
|
|
|
|
echo [6/7] Showing running services...
|
|
docker compose --env-file .production.env -f production.compose.yml ps
|
|
|
|
echo [7/7] Done.
|
|
echo API should be available at http://localhost:3000 (or API_PORT in .production.env)
|
|
echo Stop stack with:
|
|
echo docker compose --env-file .production.env -f production.compose.yml down
|
|
popd >nul
|
|
exit /b 0 |