Skip to content

Instantly share code, notes, and snippets.

@nanmu42
Last active May 15, 2019 08:01
Show Gist options
  • Save nanmu42/1120395229cecb4a89b7c8f50380b6dd to your computer and use it in GitHub Desktop.
Save nanmu42/1120395229cecb4a89b7c8f50380b6dd to your computer and use it in GitHub Desktop.
Docker loves Vue.js
FROM node:10.15 as builder
WORKDIR /project
COPY . .
RUN npm i && npm run lint && npm run build && rm -f dist/**/*.map
FROM nginx:stable
# COPY copies folder content, not folder itself
COPY --from=builder /project/dist /var/www
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
server {
server_tokens off;
listen 80;
server_name _;
root /var/www/;
index index.html;
access_log off;
gzip on;
gzip_http_version 1.0;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_buffers 16 8k;
gzip_types text/html text/css application/javascript text/javascript application/x-javascript text/plain application/json text/xml application/xml application/xml+rss;
location = /index.html {
add_header Cache-Control "no-cache";
}
location = /service-worker.js {
expires 30m;
add_header Cache-Control "public";
}
location ~* \.(js|css|html|jpe?g|png|gif|ico)$ {
# use root, don't try files
expires 30d;
add_header Cache-Control "public";
}
location / {
try_files $uri /index.html;
}
}
module.exports = {
// Setting this to false can speed up production builds
// if you don't need source maps for production.
productionSourceMap: false,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment