Run testcafe in docker with angular app running in nginx

  angular, docker, dockerfile, nginx, testcafe

I am trying to build a docker image that lifts the angular application with nginx and in turn runs the tests using testcafe. I have:

FROM node:10-alpine as builder
WORKDIR /project
COPY package*.json ./
COPY . .
RUN $(npm bin)/ng build --prod --output-path=dist

FROM nginx:1.13.8-alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
WORKDIR /usr/share/nginx/html
COPY --from=builder /project/dist .

FROM testcafe/testcafe as test
WORKDIR /project
COPY e2e ./e2e
RUN testcafe 'chromium:headless --no-sandbox --disable-dev-shm-usage --disable-setuid-sandbox' e2e

And my docker-compose is:

version: "3.3"
services:
  nginx:
    build:
      context: ./
      dockerfile: dockerfile
    restart: on-failure
    ports:
      - "4200:80"

But it seems that can’t go to localhost:80 where nginx is running the app.

A request to "http://localhost/" has failed.
      Use quarantine mode to perform additional attempts to execute this
      test.

Who could I deploy and run tests inside docker?

Source: Docker Questions

LEAVE A COMMENT