-
Notifications
You must be signed in to change notification settings - Fork 9
/
Dockerfile_quality
43 lines (34 loc) · 1.4 KB
/
Dockerfile_quality
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
FROM node:12-alpine
ARG ENV_CONFIGURATION="test"
ENV ENV_CONFIGURATION=$ENV_CONFIGURATION
# CodeClimate reporter environment varibales:
ARG CODE_CLIMATE_REPORTER_ID
ARG CI_NAME
ENV CI_NAME=$CI_NAME
ENV CODE_CLIMATE_REPORTER_ID=$CODE_CLIMATE_REPORTER_ID
ARG GIT_COMMIT_SHA
ENV GIT_COMMIT_SHA=$GIT_COMMIT_SHA
ARG GIT_BRANCH
ENV GIT_BRANCH=$GIT_BRANCH
# Update sysdem packages and install necessary ones
RUN apk add --update
RUN apk --no-cache add ca-certificates unzip wget curl bash
# Set up CodeClimate reporter.
RUN curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > cc-test-reporter
RUN chmod +x cc-test-reporter
# Use changes to package.json to force Docker not to use the cache
# when we change our application's nodejs dependencies:
COPY package.json /tmp/package.json
COPY package-lock.json /tmp/package-lock.json
RUN cd /tmp && npm install
RUN mkdir -p /quote-app-api && cp -a /tmp/node_modules /quote-app-api
# From here we load our application's code in, therefore the previous docker
# "layer" that has been cached, will be used if possible
WORKDIR /quote-app-api
COPY . /quote-app-api
# Run code quality tools:
RUN npm run lint
RUN npm test
# Upload test coverage report to CodeCov and CodeClimate.
RUN export GIT_COMMITTED_AT="$(date +%s)" && /cc-test-reporter after-build -t lcov -r $(echo $CODE_CLIMATE_REPORTER_ID) -p ./coverage
# Code quality check completed!