0
votes

I created a Dockerfile that creates a cypress image, install all dependencies, copies necessary folders, and CMD commands to run the tests. I was able to build the docker image locally, and the test run when running the image locally.

I am trying run the test in Azure Devops pipelines. I created a new pipeline using the Dockerfile I created. In my pipeline I am able to get the cypress image to build, but the tests are not running after the image is built.

I am missing something? After the image in built in the pipeline, I do need to run the image? If so I would I do that in the yaml file?

1

1 Answers

0
votes

The CMD instruction is to be executed when running the image. The image cannot be ran automatically after it was built. So you have to use docker run.

You can use a powershell task to run your docker build and run command instead of docker tasks.

In below example, i run docker build command to build my dockerfile and then run docker run command to start my image. Then I can view the execution results from the powershell task summary log.

- powershell: |
    cd $(system.defaultworkingdirectory) #cd to the directory where dockerfile resides.
    docker build -t myapp .
    docker run --rm myapp

If you want to use docker tasks to build your dockerfile, you can also try using RUN to execute your Cypress test instead of putting the test execution command in CMD commands in your dockerfile which can only be executed when run the image.