Created
November 2, 2018 10:01
-
-
Save pumano/58a138c22c142e0eee5003abf1f49e0d to your computer and use it in GitHub Desktop.
Angular + Nginx + Docker = Production
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
node_modules | |
dist |
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
version: '3.1' | |
services: | |
frontend: | |
build: . | |
ports: | |
- 80:80 |
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
######################### BUILD ######################## | |
FROM node:10 as build-stage | |
WORKDIR /app | |
COPY package*.json /app/ | |
RUN npm install | |
COPY . /app | |
RUN npm run build:prod | |
###################### DEPLOY ########################### | |
FROM nginx:alpine | |
## Remove default nginx website | |
RUN rm -rf /usr/share/nginx/html/* | |
## Copy all needed files to | |
COPY --from=build-stage /app/dist/app /usr/share/nginx/html | |
# Copy the default nginx.conf if needed | |
COPY --from=build-stage /app/nginx.conf /etc/nginx/conf.d/default.conf | |
EXPOSE 80 | |
CMD ["nginx", "-g", "daemon off;"] |
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
server { | |
listen 80; | |
server_name localhost; | |
root /usr/share/nginx/html; | |
index index.html index.htm; | |
include /etc/nginx/mime.types; | |
gzip on; | |
gzip_min_length 1000; | |
gzip_proxied expired no-cache no-store private auth; | |
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript; | |
location / { | |
try_files $uri $uri/ /index.html; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment