Skip to content

Commit 828faee

Browse files
majguoyiliuTo
authored andcommitted
use 'az acr build' to build docker image in acr
Signed-off-by: Jianguo Ma <[email protected]>
1 parent 1e3d8f3 commit 828faee

File tree

2 files changed

+16
-69
lines changed

2 files changed

+16
-69
lines changed

asset-manager/scripts/deploy-to-azure.cmd

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,6 @@ if %ERRORLEVEL% neq 0 (
6363
echo Azure CLI not found. Please install it: https://docs.microsoft.com/cli/azure/install-azure-cli
6464
exit /b 1
6565
)
66-
67-
where docker >nul 2>&1
68-
if %ERRORLEVEL% neq 0 (
69-
echo Docker not found. Please install it: https://docs.docker.com/get-docker/
70-
exit /b 1
71-
)
7266
echo Prerequisites satisfied.
7367

7468
echo Please ensure you are logged into Azure before running this script.
@@ -299,43 +293,22 @@ if %ERRORLEVEL% neq 0 (
299293
)
300294
echo Web and worker modules built.
301295

302-
rem Build and push Docker images to ACR
303-
echo Building and pushing Docker images to ACR...
304-
305296
rem Web module
306-
echo Building web Docker image...
307-
docker build -t !AcrLoginServer!/%WebAppName%:latest --file .\web\Dockerfile .\web
297+
echo Building web Docker image in ACR...
298+
cmd /c az acr build -t %WebAppName%:latest -r %AcrName% --file .\web\Dockerfile .\web
308299
if %ERRORLEVEL% neq 0 (
309-
echo Failed to build Web Docker image. Exiting.
300+
echo Failed to build Web Docker image in ACR. Exiting.
310301
exit /b 1
311302
)
303+
echo Web Docker image built and pushed to ACR.
312304
rem Worker module
313-
echo Building worker Docker image...
314-
docker build -t !AcrLoginServer!/%WorkerAppName%:latest --file .\worker\Dockerfile .\worker
315-
if %ERRORLEVEL% neq 0 (
316-
echo Failed to build Worker Docker image. Exiting.
317-
exit /b 1
318-
)
319-
cmd /c az acr login --name %AcrName%
320-
if %ERRORLEVEL% neq 0 (
321-
echo Failed to log in to ACR. Exiting.
322-
exit /b 1
323-
)
324-
echo Logged in to ACR.
325-
echo Pushing web Docker image to ACR...
326-
docker push !AcrLoginServer!/%WebAppName%:latest
327-
if %ERRORLEVEL% neq 0 (
328-
echo Failed to push Web Docker image to ACR. Exiting.
329-
exit /b 1
330-
)
331-
echo Web Docker image pushed to ACR.
332-
echo Pushing worker Docker image to ACR...
333-
docker push !AcrLoginServer!/%WorkerAppName%:latest
305+
echo Building worker Docker image in ACR...
306+
cmd /c az acr build -t %WorkerAppName%:latest -r %AcrName% --file .\worker\Dockerfile .\worker
334307
if %ERRORLEVEL% neq 0 (
335-
echo Failed to push Worker Docker image to ACR. Exiting.
308+
echo Failed to build Worker Docker image in ACR. Exiting.
336309
exit /b 1
337310
)
338-
echo Worker Docker image pushed to ACR.
311+
echo Worker Docker image built and pushed to ACR.
339312

340313
rem Create Container Apps with user-assigned managed identities
341314
echo Creating Container App for web module...

asset-manager/scripts/deploy-to-azure.sh

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ if ! command -v az &> /dev/null; then
5757
echo "Azure CLI not found. Please install it: https://docs.microsoft.com/cli/azure/install-azure-cli"
5858
exit 1
5959
fi
60-
61-
if ! command -v docker &> /dev/null; then
62-
echo "Docker not found. Please install it: https://docs.docker.com/get-docker/"
63-
exit 1
64-
fi
6560
echo "Prerequisites satisfied."
6661

6762
echo "Please ensure you are logged into Azure before running this script."
@@ -280,43 +275,22 @@ if [ $? -ne 0 ]; then
280275
fi
281276
echo "Web and worker modules built."
282277

283-
# Build and push Docker images to ACR
284-
echo "Building and pushing Docker images to ACR..."
285-
286278
# Web module
287-
echo "Building web Docker image..."
288-
docker build -t "${AcrLoginServer}/${WebAppName}:latest" --file ./web/Dockerfile ./web
279+
echo "Building web Docker image in ACR..."
280+
az acr build -t "${WebAppName}:latest" -r $AcrName --file ./web/Dockerfile ./web
289281
if [ $? -ne 0 ]; then
290-
echo "Failed to build Web Docker image. Exiting."
282+
echo "Failed to build Web Docker image in ACR. Exiting."
291283
exit 1
292284
fi
285+
echo "Web Docker image built and pushed to ACR."
293286
# Worker module
294-
echo "Building worker Docker image..."
295-
docker build -t "${AcrLoginServer}/${WorkerAppName}:latest" --file ./worker/Dockerfile ./worker
296-
if [ $? -ne 0 ]; then
297-
echo "Failed to build Worker Docker image. Exiting."
298-
exit 1
299-
fi
300-
az acr login --name "$AcrName"
301-
if [ $? -ne 0 ]; then
302-
echo "Failed to log in to ACR. Exiting."
303-
exit 1
304-
fi
305-
echo "Logged in to ACR."
306-
echo "Pushing web Docker image to ACR..."
307-
docker push "${AcrLoginServer}/${WebAppName}:latest"
308-
if [ $? -ne 0 ]; then
309-
echo "Failed to push Web Docker image to ACR. Exiting."
310-
exit 1
311-
fi
312-
echo "Web Docker image pushed to ACR."
313-
echo "Pushing worker Docker image to ACR..."
314-
docker push "${AcrLoginServer}/${WorkerAppName}:latest"
287+
echo "Building worker Docker image in ACR..."
288+
az acr build -t "${WorkerAppName}:latest" -r $AcrName --file ./worker/Dockerfile ./worker
315289
if [ $? -ne 0 ]; then
316-
echo "Failed to push Worker Docker image to ACR. Exiting."
290+
echo "Failed to build Worker Docker image in ACR. Exiting."
317291
exit 1
318292
fi
319-
echo "Worker Docker image pushed to ACR."
293+
echo "Worker Docker image built and pushed to ACR."
320294

321295
# Create Container Apps with user-assigned managed identity for web module
322296
echo "Creating Container App for web module..."

0 commit comments

Comments
 (0)