0

I am running a Azure DevOps build through a self hosted VMSS agent pool. The stand-by vms is 0, so when I trigger a build, it creates a VM. The VMSS agent installs docker with a cloud-init script. The contents of it is as follows:

#cloud-config
bootcmd:
  - systemctl daemon-reload
  
package_update: true
package_upgrade: true
packages:
  - apt-transport-https
  - ca-certificates
  - curl
  - gnupg-agent
  - software-properties-common
  - docker-ce
  - docker-ce-cli
groups:
 - docker

runcmd:
  - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
  - add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  - apt-get update -y
  - apt-get install -y docker-ce docker-ce-cli containerd.io
  - systemctl start docker
  - systemctl enable docker
  - docker pull einlinuus/testing:node
  - docker run -d -p 80:80 einlinuus/testing:node
  - sudo usermod -aG docker $USER
  - sudo systemctl restart docker

The pipeline builds a image of a node.js application with a Docker File

FROM node:16-alpine as build

WORKDIR /app
COPY . .
RUN npm ci
RUN npm audit fix
RUN npm run build // This line is throwing the below error


FROM node:16-alpine
WORKDIR /app
COPY --from=build /app/package*.json ./ 
RUN npm ci --omit-dev --ignore-scripts
RUN npm audit fix
COPY --from=build /app/build ./build
RUN apk add libcap2
EXPOSE 5173
USER node
ENV PORT=5173
CMD ["node", "./build/index.js"]

Sometimes, when I delete the existing virtual agent scale set from the portal and i run the agent pool with a new scale set, I am getting this error: I have verified that docker is installed in the agent.

    #10 [build 6/6] RUN npm run build
    #10 1.433 
    #10 1.433 > alarm-dev@0.0.1 build
#10 11.47                     ^
#10 11.47 17:     /**
#10 11.47 18:    * @type {any}
ERROR: failed to solve: Unavailable: error reading from server: EOF
##[debug]Exit code 1 received from tool '/usr/bin/docker'
##[debug]STDIO streams have closed for tool '/usr/bin/docker'
##[error]#1 [internal] load .dockerignore
##[debug]Processed: ##vso[task.issue type=error;]#1 [internal] load .dockerignore
##[error]#1 transferring context: 2B done

This also occurs in the condition when the VMSS is provisioning its agent due to a build, Sometimes if the agent(VM) is already present it does not occur

Can anyone help here? Thanks

Coder
  • 39
  • 6

0 Answers0