Last active
August 24, 2018 02:35
-
-
Save blabadi/adc995e96a4c257639d2288601558a30 to your computer and use it in GitHub Desktop.
Angular Dockerizing files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules | |
.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
nutracker-prod: | |
container_name: nutracker-prod | |
build: | |
context: . | |
dockerfile: Dockerfile | |
args: | |
BUILD_ENV: alpha | |
ports: | |
- '8008:8008' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################### | |
### build environment ### | |
######################### | |
# base image | |
FROM node:9.6.1 as builder | |
# 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 | |
# set working directory | |
RUN mkdir /usr/src/app | |
WORKDIR /usr/src/app | |
# add `/usr/src/app/node_modules/.bin` to $PATH | |
ENV PATH /usr/src/app/node_modules/.bin:$PATH | |
# install and cache app dependencies | |
COPY package.json /usr/src/app/package.json | |
RUN npm install | |
RUN npm install -g @angular/cli@6.1.4 --unsafe | |
# add app | |
COPY . /usr/src/app | |
ARG BUILD_ENV | |
# run tests | |
#RUN ng test --watch=false | |
# generate build | |
RUN ng build -c $BUILD_ENV | |
################## | |
### production ### | |
################## | |
# base image | |
FROM nginx:1.13.9-alpine | |
# copy artifact build from the 'build environment' | |
COPY --from=builder /usr/src/app/dist /usr/share/nginx/html | |
COPY ./nginx-custom.conf /etc/nginx/conf.d/default.conf | |
# expose nginx port 8008 (should match nginx config) | |
EXPOSE 8008 | |
# run nginx | |
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 8008; | |
location ~ ^/(api|oauth) { | |
proxy_pass http://18.222.254.118:8080; | |
} | |
location / { | |
root /usr/share/nginx/html; | |
index index.html index.htm; | |
try_files $uri $uri/ /index.html =404; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment