Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 1 | |
| 2 | # ============LICENSE_START========================================== |
| 3 | #=================================================================== |
| 4 | #Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. |
| 5 | #=================================================================== |
| 6 | |
| 7 | #Unless otherwise specified, all software contained herein is licensed |
| 8 | #under the Apache License, Version 2.0 (the License); |
| 9 | #you may not use this software except in compliance with the License. |
| 10 | #You may obtain a copy of the License at |
| 11 | |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | |
| 14 | #Unless required by applicable law or agreed to in writing, software |
| 15 | #distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | #WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | #See the License for the specific language governing permissions and |
| 18 | #limitations under the License. |
| 19 | |
| 20 | #ECOMP is a trademark and service mark of AT&T Intellectual Property. |
| 21 | #============LICENSE_END============================================ |
| 22 | |
| 23 | ### STAGE 1: Build ### |
| 24 | |
| 25 | # We label our stage as 'builder' |
| 26 | FROM node:8-alpine as builder |
| 27 | |
| 28 | COPY package.json . |
| 29 | |
| 30 | RUN npm set progress=false && npm config set depth 0 && npm cache clean --force |
| 31 | |
| 32 | ## Storing node modules on a separate layer will prevent unnecessary npm installs at each build |
| 33 | RUN npm i && mkdir /ng-app && cp -R ./node_modules ./ng-app |
| 34 | |
| 35 | WORKDIR /ng-app |
| 36 | |
| 37 | COPY . . |
| 38 | |
| 39 | ## Build the angular app in production mode and store the artifacts in dist folder |
| 40 | RUN $(npm bin)/ng build --env=prod |
| 41 | |
| 42 | |
| 43 | ### STAGE 2: Setup ### |
| 44 | |
| 45 | FROM nginx:1.13.3-alpine |
| 46 | |
| 47 | ## Copy our default nginx config |
| 48 | COPY nginx/default.conf /etc/nginx/conf.d/ |
| 49 | |
| 50 | ## Remove default nginx website |
| 51 | RUN rm -rf /usr/share/nginx/html/* |
| 52 | |
| 53 | ## From 'builder' stage copy over the artifacts in dist folder to default nginx public folder |
| 54 | COPY --from=builder /ng-app/dist /usr/share/nginx/html |
| 55 | |
| 56 | CMD ["nginx", "-g", "daemon off;"] |