Skip to content

Commit 7b271af

Browse files
authored
Add nginx config for SPAs to real world docker example
fixes vuejs#2818
1 parent b73ab9c commit 7b271af

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/v2/cookbook/dockerize-vuejs-app.md

+14
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ Nevertheless, for realistically complex production use cases, it may be wiser to
6161

6262
Let's refactor our `Dockerfile` to use NGINX:
6363

64+
1. Create an NGINX config file called `nginx/nginx.conf`
65+
66+
```conf
67+
server {
68+
location / {
69+
# This would be the directory where Vue's static files are stored.
70+
root /usr/share/nginx/html;
71+
try_files $uri /index.html;
72+
}
73+
}
74+
```
75+
2. Change your Dockerfile to
76+
6477
```docker
6578
# build stage
6679
FROM node:lts-alpine as build-stage
@@ -72,6 +85,7 @@ RUN npm run build
7285
7386
# production stage
7487
FROM nginx:stable-alpine as production-stage
88+
COPY ./nginx/nginx.conf /etc/nginx/conf.d/default.conf
7589
COPY --from=build-stage /app/dist /usr/share/nginx/html
7690
EXPOSE 80
7791
CMD ["nginx", "-g", "daemon off;"]

0 commit comments

Comments
 (0)