2018-03-05 14:45:36 +01:00
|
|
|
|
# Usage:
|
2017-05-31 16:38:18 +02:00
|
|
|
|
#
|
2018-03-05 14:45:36 +01:00
|
|
|
|
# Build image:
|
2017-05-31 16:38:18 +02:00
|
|
|
|
# docker build -t angular-starter .
|
|
|
|
|
|
#
|
|
|
|
|
|
# Run image (on localhost:8080):
|
2018-03-05 14:45:36 +01:00
|
|
|
|
# docker run --name angular-starter -p 8080:80 angular-starter
|
2017-05-31 16:38:18 +02:00
|
|
|
|
#
|
|
|
|
|
|
# Run image as virtual host (read more: https://github.com/jwilder/nginx-proxy):
|
2018-03-05 14:45:36 +01:00
|
|
|
|
# docker run -e VIRTUAL_HOST=angular-starter.your-domain.com --name angular-starter angular-starter
|
2017-05-31 16:38:18 +02:00
|
|
|
|
|
2018-02-27 17:52:19 +01:00
|
|
|
|
# Stage 1, based on Node.js, to build and compile Angular
|
|
|
|
|
|
|
|
|
|
|
|
FROM node:8.9.4-alpine as builder
|
|
|
|
|
|
|
|
|
|
|
|
COPY package.json ./
|
|
|
|
|
|
|
|
|
|
|
|
## Storing node modules on a separate layer will prevent unnecessary npm installs at each build
|
|
|
|
|
|
RUN npm i && mkdir /ng-app && mv ./node_modules ./ng-app
|
|
|
|
|
|
|
|
|
|
|
|
WORKDIR /ng-app
|
|
|
|
|
|
|
|
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
|
|
|
|
RUN npm run build:aot:prod
|
|
|
|
|
|
|
|
|
|
|
|
# Stage 2, based on Nginx, to have only the compiled app, ready for production with Nginx
|
|
|
|
|
|
|
|
|
|
|
|
FROM nginx:1.13.9-alpine
|
|
|
|
|
|
|
|
|
|
|
|
COPY ./config/nginx-custom.conf /etc/nginx/conf.d/default.conf
|
|
|
|
|
|
|
|
|
|
|
|
## Remove default nginx website
|
|
|
|
|
|
RUN rm -rf /usr/share/nginx/html/*
|
|
|
|
|
|
|
2018-03-05 14:45:36 +01:00
|
|
|
|
## From ‘builder’ stage copy over the artifacts in dist folder to default nginx public folder
|
2018-02-27 17:52:19 +01:00
|
|
|
|
COPY --from=builder /ng-app/dist /usr/share/nginx/html
|
|
|
|
|
|
|
2018-03-05 14:45:36 +01:00
|
|
|
|
CMD ["nginx", "-g", "daemon off;"]
|