For Frontend practice
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
@echo off
|
||||
setlocal EnableExtensions EnableDelayedExpansion
|
||||
|
||||
set "ROOT_DIR=%~dp0.."
|
||||
set "IMAGE_OUT_DIR=%ROOT_DIR%\images"
|
||||
set "ARCHIVE_FILE=%IMAGE_OUT_DIR%\webstore-production-images.tar"
|
||||
|
||||
set "API_IMAGE=webstore-api:prod"
|
||||
set "DB_IMAGE=postgres:16-alpine"
|
||||
|
||||
echo [1/6] Checking Docker availability...
|
||||
docker --version >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo ERROR: Docker CLI is not available. Install Docker Desktop first.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [2/6] Building production API image: %API_IMAGE%
|
||||
pushd "%ROOT_DIR%" >nul
|
||||
docker build -t "%API_IMAGE%" -f Dockerfile .
|
||||
if errorlevel 1 (
|
||||
popd >nul
|
||||
echo ERROR: Failed to build API image.
|
||||
exit /b 1
|
||||
)
|
||||
popd >nul
|
||||
|
||||
echo [3/6] Pulling database image: %DB_IMAGE%
|
||||
docker pull "%DB_IMAGE%"
|
||||
if errorlevel 1 (
|
||||
echo ERROR: Failed to pull database image.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [4/6] Preparing image output directory: %IMAGE_OUT_DIR%
|
||||
if not exist "%IMAGE_OUT_DIR%" mkdir "%IMAGE_OUT_DIR%"
|
||||
|
||||
echo [5/6] Exporting images to archive...
|
||||
if exist "%ARCHIVE_FILE%" del /f /q "%ARCHIVE_FILE%"
|
||||
docker save -o "%ARCHIVE_FILE%" "%API_IMAGE%" "%DB_IMAGE%"
|
||||
if errorlevel 1 (
|
||||
echo ERROR: Failed to export Docker images.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [6/6] Done.
|
||||
echo Created archive: "%ARCHIVE_FILE%"
|
||||
echo Share this file with students together with production.compose.yml and .production.env.
|
||||
exit /b 0
|
||||
Reference in New Issue
Block a user