Многоступенчатая задача в Azure - PullRequest
0 голосов
/ 04 августа 2020

Я создал многоступенчатую задачу с yaml на основе учебника Microsoft в azure с

az acr task create --registry pataugeoire --name multi-step --context https://github.com/myname/Planschbecken.git --file deploy-azure.yaml --git-access-token 1245

yaml выглядит так

version: v1.0.0
steps:

- build: -t {{.Run.Registry}}/pataugeoire-eu:{{.Run.ID}} -f ./src/Planschbecken/build/Dockerfile .
# Run image 
- cmd: -t {{.Run.Registry}}/pataugeoire-eu:{{.Run.ID}}
  id: pataugeoire-eu
  detach: true
  ports: ["8080:80"]
- cmd: docker stop pataugeoire-eu
# Push image
- push:
  - {{.Run.Registry}}/pataugeoire-eu:{{.Run.ID}}

после выполнения задачи я получаю следующий журнал:

2020/08/04 04:29:18 Downloading source code...
2020/08/04 04:29:22 Finished downloading source code
2020/08/04 04:29:22 Creating Docker network: acb_default_network, driver: 'bridge'
2020/08/04 04:29:22 Successfully set up Docker network: acb_default_network
2020/08/04 04:29:22 Setting up Docker configuration...
2020/08/04 04:29:23 Successfully set up Docker configuration
2020/08/04 04:29:23 Logging in to registry: pataugeoire.azurecr.io
2020/08/04 04:29:24 Successfully logged into pataugeoire.azurecr.io
2020/08/04 04:29:24 Executing step ID: acb_step_0. Timeout(sec): 600, Working directory: '', Network: 'acb_default_network'
2020/08/04 04:29:24 Scanning for dependencies...
2020/08/04 04:29:24 Successfully scanned dependencies
2020/08/04 04:29:24 Launching container with name: acb_step_0
Sending build context to Docker daemon  36.86kB
Step 1/16 : FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
3.1-buster-slim: Pulling from dotnet/core/aspnet
6ec8c9369e08: Pulling fs layer
fe8522826504: Pulling fs layer
658bf4619169: Pulling fs layer
0392978bbc2e: Pulling fs layer
33dd02257803: Pulling fs layer
0392978bbc2e: Waiting
33dd02257803: Waiting
658bf4619169: Verifying Checksum
658bf4619169: Download complete
fe8522826504: Verifying Checksum
fe8522826504: Download complete
6ec8c9369e08: Verifying Checksum
6ec8c9369e08: Download complete
0392978bbc2e: Verifying Checksum
0392978bbc2e: Download complete
33dd02257803: Verifying Checksum
33dd02257803: Download complete
6ec8c9369e08: Pull complete
fe8522826504: Pull complete
658bf4619169: Pull complete
0392978bbc2e: Pull complete
33dd02257803: Pull complete
Digest: sha256:8a92e24da3f05e870352a59318dc757fa8f439257aee72bd429fb32e8235c6a8
Status: Downloaded newer image for mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim
 ---> 5d7a95ed1660
Step 2/16 : WORKDIR /app
 ---> Running in 0f7fe00fda83
Removing intermediate container 0f7fe00fda83
 ---> 1136339126be
Step 3/16 : EXPOSE 80
 ---> Running in 8d6c428499f2
Removing intermediate container 8d6c428499f2
 ---> aafe67b81817
Step 4/16 : FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
3.1-buster: Pulling from dotnet/core/sdk
31dd5ebca5ef: Pulling fs layer
3ed641c4ae98: Pulling fs layer
bcd57146431e: Pulling fs layer
ac34a4d7c330: Pulling fs layer
ea642ea828f8: Pulling fs layer
a6f91215615a: Pulling fs layer
9ab383195132: Pulling fs layer
ac34a4d7c330: Waiting
ea642ea828f8: Waiting
a6f91215615a: Waiting
9ab383195132: Waiting
3ed641c4ae98: Verifying Checksum
3ed641c4ae98: Download complete
bcd57146431e: Verifying Checksum
bcd57146431e: Download complete
ea642ea828f8: Verifying Checksum
ea642ea828f8: Download complete
31dd5ebca5ef: Verifying Checksum
31dd5ebca5ef: Download complete
ac34a4d7c330: Verifying Checksum
ac34a4d7c330: Download complete
a6f91215615a: Verifying Checksum
a6f91215615a: Download complete
9ab383195132: Verifying Checksum
9ab383195132: Download complete
31dd5ebca5ef: Pull complete
3ed641c4ae98: Pull complete
bcd57146431e: Pull complete
ac34a4d7c330: Pull complete
ea642ea828f8: Pull complete
a6f91215615a: Pull complete
9ab383195132: Pull complete
Digest: sha256:7aa45680ecf79dd9288056511c08b2c40411869b9ab89a0b51aade1f83fcc12e
Status: Downloaded newer image for mcr.microsoft.com/dotnet/core/sdk:3.1-buster
 ---> 925a86b607a3
Step 5/16 : WORKDIR /src
 ---> Running in 90742e31913f
Removing intermediate container 90742e31913f
 ---> 8b7410599293
Step 6/16 : COPY ["./src/Planschbecken/Planschbecken.csproj", ""]
 ---> 324f46346cf6
Step 7/16 : RUN dotnet restore "./Planschbecken.csproj"
 ---> Running in 246ad54a5b12
  Determining projects to restore...
  Restored /src/Planschbecken.csproj (in 1.04 sec).
Removing intermediate container 246ad54a5b12
 ---> ccc23072a246
Step 8/16 : COPY . .
 ---> 18b52c99b9ad
Step 9/16 : WORKDIR "/src/."
 ---> Running in 67e0a650d5af
Removing intermediate container 67e0a650d5af
 ---> 9426eacd4951
Step 10/16 : RUN dotnet build "Planschbecken.csproj" -c Release -o /app/build
 ---> Running in d665c57c7598
Microsoft (R) Build Engine version 16.6.0+5ff7b0c9e for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  Planschbecken -> /app/build/Planschbecken.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.30
Removing intermediate container d665c57c7598
 ---> 39254ff6b129
Step 11/16 : FROM build AS publish
 ---> 39254ff6b129
Step 12/16 : RUN dotnet publish "Planschbecken.csproj" -c Release -o /app/publish
 ---> Running in 26bd2e4d0e21
Microsoft (R) Build Engine version 16.6.0+5ff7b0c9e for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  Planschbecken -> /src/bin/Release/netcoreapp3.1/Planschbecken.dll
  Planschbecken -> /app/publish/
Removing intermediate container 26bd2e4d0e21
 ---> 9cfd1ab1a249
Step 13/16 : FROM base AS final
 ---> aafe67b81817
Step 14/16 : WORKDIR /app
 ---> Running in ac345cd72236
Removing intermediate container ac345cd72236
 ---> 526f22fd95d0
Step 15/16 : COPY --from=publish /app/publish .
 ---> 02da76c66090
Step 16/16 : ENTRYPOINT ["dotnet", "Planschbecken.dll"]
 ---> Running in 748b1470c1e3
Removing intermediate container 748b1470c1e3
 ---> 8e16f072fb69
Successfully built 8e16f072fb69
Successfully tagged pataugeoire.azurecr.io/pataugeoire-eu:cb1s
2020/08/04 04:30:04 Successfully executed container: acb_step_0
2020/08/04 04:30:04 Executing step ID: pataugeoire-eu. Timeout(sec): 600, Working directory: '', Network: 'acb_default_network'
2020/08/04 04:30:04 Launching container with name: pataugeoire-eu
e61815831412e20351a491d0318863c28171cb2d23f6e373214703706fde4223
2020/08/04 04:30:05 Successfully executed container: pataugeoire-eu
2020/08/04 04:30:05 Executing step ID: acb_step_2. Timeout(sec): 600, Working directory: '', Network: 'acb_default_network'
2020/08/04 04:30:05 Launching container with name: acb_step_2
Error response from daemon: No such container: pataugeoire-eu
2020/08/04 04:30:06 Container failed during run: acb_step_2. No retries remaining.
failed to run step ID: acb_step_2: exit status 1

Все выглядит нормально. Но в конце концов скрипт перестает работать. docker по-прежнему активен, поскольку веб-сайт все еще работает. Что я сделал не так?

Ответы [ 2 ]

0 голосов
/ 04 августа 2020

Если вы хотите запустить образ Docker после завершения сборки, вы можете использовать cmd и установить образ с именем реестра:

- cmd: $Registry/myimage:mytag

Таким образом, вам не нужно использовать команда docker run, и, кроме того, вы пропустите имя в реестре для вашего образа. Здесь - более подробная информация о cmd в задаче. И также отображается описание:

Предполагается, что изображения без префикса реестра происходят из docker .io.

0 голосов
/ 04 августа 2020

В конце есть сообщение об ошибке:

Нет такого контейнера: pataugeoire-eu

Это может быть из-за того, что вы пытаетесь запустить контейнер до него нажата.

...