add the nginx container to the frontend
This commit is contained in:
parent
567c40f6cb
commit
e8a751fd8d
|
@ -23,13 +23,4 @@ services:
|
|||
frontend:
|
||||
build: frontend/.
|
||||
ports:
|
||||
- 8080:8080
|
||||
|
||||
nginx:
|
||||
build: ./nginx
|
||||
ports:
|
||||
- 80:80
|
||||
depends_on:
|
||||
- backend
|
||||
volumes:
|
||||
- ./static:/home/app/web/static
|
||||
- 8080:80
|
||||
|
|
|
@ -1,22 +1,21 @@
|
|||
FROM node:lts-alpine
|
||||
|
||||
# install simple http server for serving static content
|
||||
RUN npm install -g http-server
|
||||
|
||||
# make the 'app' folder the current working directory
|
||||
#Docker file for VueJS using NGINX
|
||||
# build stage
|
||||
FROM node:lts-alpine as build-stage
|
||||
WORKDIR /app
|
||||
|
||||
# copy both 'package.json' and 'package-lock.json' (if available)
|
||||
COPY package*.json ./
|
||||
|
||||
# install project dependencies
|
||||
RUN apk add --update npm
|
||||
RUN npm install @vue/cli@3.7.0 -g
|
||||
RUN npm install
|
||||
|
||||
# copy project files and folders to the current working directory (i.e. 'app' folder)
|
||||
COPY . .
|
||||
|
||||
# build app for production with minification
|
||||
COPY . /app
|
||||
RUN npm run build
|
||||
|
||||
# production stage
|
||||
FROM nginx:stable-alpine as production-stage
|
||||
|
||||
COPY --from=build-stage . /usr/share/nginx/html
|
||||
RUN rm /etc/nginx/conf.d/default.conf
|
||||
COPY nginx.conf /etc/nginx/conf.d
|
||||
|
||||
ENV PORT = 8080
|
||||
EXPOSE 8080
|
||||
CMD [ "http-server", "dist" ]
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
server {
|
||||
|
||||
listen 8080;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html/app;
|
||||
index index.html index.htm;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
FROM nginx:1.17.4-alpine
|
||||
|
||||
RUN rm /etc/nginx/conf.d/default.conf
|
||||
COPY nginx.conf /etc/nginx/conf.d
|
|
@ -1,19 +0,0 @@
|
|||
upstream network_inventory {
|
||||
server web:8000;
|
||||
}
|
||||
|
||||
server {
|
||||
|
||||
listen 80;
|
||||
|
||||
location / {
|
||||
proxy_pass http://network_inventory;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Host $host;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
location /static/ {
|
||||
alias /home/app/web/static/;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue