I'm trying to dockerize angular e2e serenity.js tests with docker compose. Flow that i want to gain is having 2 services where 1 builds and run angular app and 2 build e2e tests project and waits for command to execute them by docker-compose exec e2e npm run test
.The problem is that after running this command tests fails because container doesnt have access in browser to app running in second container even though i use proper url http://app:4200
.
anuglar app dockerfile
FROM node:12
# Exclude the NPM cache from the image
VOLUME /root/.npm
WORKDIR /usr/app
# Copy npm config
COPY ./.npmrc /root/.npmrc
# create app
ENV PATH ./node_modules/.bin:$PATH
COPY ./package*.json ./
RUN npm install -g @angular/cli@latest \
&& npm ci
COPY . .
# run app
CMD ng serve --proxy-config proxy.conf.json --host 0.0.0.0
e2e tests dockerfile
FROM node:12
ARG CHROME_VERSION="87.0.4280.88-1"
WORKDIR /usr/e2e
RUN wget --no-verbose -O /tmp/chrome.deb http://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}_amd64.deb \
&& apt-get update \
&& apt-get install -y /tmp/chrome.deb \
&& rm /tmp/chrome.deb
COPY package*.json ./
RUN npm ci
COPY . .
docker-compose.yaml
version: '3.7'
services:
app:
container_name: app
build:
context: ../my-app
dockerfile: Dockerfile-local
volumes:
- '../my-app/app:/usr/app'
- '/usr/app/node_modules'
ports:
- '4200:4200'
e2e:
container_name: e2e
build:
context: .
dockerfile: Dockerfile
volumes:
- '.:/usr/e2e'
- '/usr/e2e/node_modules'
tty: true
stdin_open: true
fixed after adding --disable-host-check to ng serve
command defined in Dockerfile running angular app
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.