Last active
December 14, 2017 19:13
-
-
Save roalcantara/e39a3c9202900dfcf9a2b3a30b3f3d5f to your computer and use it in GitHub Desktop.
Dockerized GIT Deployment Angular2 on Nginx
This file contains hidden or 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
| FROM alpine/git:latest AS git | |
| MAINTAINER roalcantara <rogerio.alcantara@gmail.com> | |
| # Required Environment Variables | |
| ARG NG_ENV=prod | |
| ARG GIT_REPO | |
| ARG GIT_BRANCH=master | |
| ## Clone the git repository | |
| WORKDIR /repo | |
| RUN git clone -b $GIT_BRANCH $GIT_REPO . | |
| ## Build the angular app for the given environment | |
| FROM node:alpine AS build | |
| ARG NG_ENV=prod | |
| RUN npm set progress=false && npm config set depth 0 | |
| WORKDIR /app | |
| COPY --from=git /repo . | |
| RUN npm install | |
| RUN $(npm bin)/ng build -e=$NG_ENV | |
| # Start from a new nginx image | |
| FROM nginx:alpine | |
| COPY --from=build /app/dist /usr/share/nginx/html/ | |
| CMD ["nginx", "-g", "daemon off;"] | |
| EXPOSE 80 | |
| RUN echo "COWABUNGA! 😎" | |
| # == QuickStart | |
| # | |
| # mkdir Docker && cd Docker | |
| # curl -o Dockerfile https://gist.githubusercontent.com/roalcantara/e39a3c9202900dfcf9a2b3a30b3f3d5f/raw/ | |
| # docker build --build-arg NG_ENV=prod --build-arg GIT_REPO=https://token@bitbucket.org/user/repo.git --build-arg GIT_BRANCH=master -t ng-app . | |
| # docker run -d -p 8080:80 ng-app | |
| # open http://localhost:8080 | |
| # | |
| # Thanks to: https://github.com/avatsaev/angular4-docker-example/blob/master/Dockerfile | |
| # Special Thanks to: https://medium.com/@mikaoelitiana |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment