Skip to content

Instantly share code, notes, and snippets.

@xinyii
Created May 8, 2021 06:08
Show Gist options
  • Save xinyii/ad6568276ffd3500a4f7e08d389557ad to your computer and use it in GitHub Desktop.
Save xinyii/ad6568276ffd3500a4f7e08d389557ad to your computer and use it in GitHub Desktop.
[Docker deploy front-end] #docker
FROM node:alpine as builder
WORKDIR /usr/src/app
COPY package.json ./
RUN yarn install
ADD src ./src
ADD *.json ./
ADD *.conf.js ./
ADD e2e ./e2e
RUN yarn run build
FROM nginx:alpine
COPY --from=builder /usr/src/app/dist /usr/share/nginx/html
RUN chmod -R 777 /usr/share/nginx/html/*
COPY nginx.conf /etc/nginx/conf.d/default.conf
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}
location /api {
proxy_pass http://server:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment