Skip to content

Instantly share code, notes, and snippets.

@matthewoestreich
Last active May 4, 2019 06:31
Show Gist options
  • Save matthewoestreich/1150f8df652a11da294fd4b5857013bf to your computer and use it in GitHub Desktop.
Save matthewoestreich/1150f8df652a11da294fd4b5857013bf to your computer and use it in GitHub Desktop.
Docker and NGINX for Vue History Mode
server {
listen 80 default_server;
listen [::]:80 default_server;
root /usr/share/nginx/html;
index index.html;
location / {
# Support the HTML5 History mode of the vue-router.
# https://router.vuejs.org/en/essentials/history-mode.html
try_files $uri $uri/ /index.html;
}
}
FROM node:lts-alpine AS build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# production stage
# - this line was throwing errors, something is up with Jenkins Docker plugin -
# FROM nginx:stable-alpine as production-stage
FROM nginx:stable-alpine
#### THIS LINE! YOU ALSO NEED THE NGINX CONF FILE
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build-stage /app/docs /usr/share/nginx/html
EXPOSE 80:1337
CMD ["nginx", "-g", "daemon off;"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment