Skip to content
Snippets Groups Projects
Commit a60e10ad authored by Richard Henck's avatar Richard Henck
Browse files

Add Docker files and scripts

By running "docker-compose -f docker/docker-compose.yml up" the frontend 
and a mock backend can be run. This enables unit and e2e testing.

There is also a Dockerfile for producing a production ready container 
using nginx as base.

The specs.yml file serves as an API definition for the backend mock 
container. This needs to be updated (i.e. copied over) manually whenever 
the backend API changes. This workflow may be improved in the future.
parent 73e4df7e
No related branches found
No related tags found
No related merge requests found
node_modules
.git
.gitignore
FROM node:13.14.0
# install chrome for protractor tests
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
RUN apt-get update && apt-get install -yq google-chrome-stable
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json /app/package.json
RUN npm install
# install webdriver for browser testing
RUN npm i --prefix=./node_modules/protractor --save webdriver-manager@latest
RUN npx webdriver-manager update
COPY . /app
EXPOSE 4200
CMD ng serve --disableHostCheck --host 0.0.0.0
FROM node:13.14.0 as build
# install chrome for protractor tests
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
RUN apt-get update && apt-get install -yq google-chrome-stable
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json /app/package.json
RUN npm install
# install webdriver for browser testing
RUN npm i --prefix=./node_modules/protractor --save webdriver-manager@latest
RUN npx webdriver-manager update
COPY . /app
RUN ng test --watch=false
RUN ng e2e --webdriver-update=false --port 4202
RUN ng build --output-path=dist
# ===========================================
FROM nginx:1.19.1-alpine
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
version: '3.7'
services:
testcenter-frontend:
build:
context: ../
dockerfile: docker/Dockerfile
container_name: testcenter-frontend
volumes:
- ../:/app
- /app/node_modules
ports:
- '4201:4200'
backend-mock:
image: stoplight/prism:3
volumes:
- ./scripts:/api
ports:
- '8000:4010'
command:
mock -h 0.0.0.0 "/api/specs.yml"
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment