2022-01-11 19:07:48 +08:00
|
|
|
FROM node:16.13.1-alpine as build
|
2022-01-08 19:26:11 +08:00
|
|
|
ENV VUE_APP_NETEASE_API_URL=/api
|
|
|
|
WORKDIR /app
|
2022-01-30 00:19:55 +08:00
|
|
|
RUN apk add --no-cache python3 make g++ git
|
2022-01-22 21:07:33 +08:00
|
|
|
COPY package.json yarn.lock ./
|
|
|
|
RUN yarn install
|
|
|
|
COPY . .
|
|
|
|
RUN yarn build
|
2022-01-08 19:26:11 +08:00
|
|
|
|
2022-01-11 19:07:48 +08:00
|
|
|
FROM nginx:1.20.2-alpine as app
|
2022-01-08 19:26:11 +08:00
|
|
|
RUN echo $'server { \n\
|
|
|
|
gzip on;\n\
|
|
|
|
listen 80; \n\
|
|
|
|
listen [::]:80; \n\
|
|
|
|
server_name localhost; \n\
|
|
|
|
\n\
|
|
|
|
location / { \n\
|
2022-01-30 00:19:55 +08:00
|
|
|
root /usr/share/nginx/html; \n\
|
|
|
|
index index.html; \n\
|
|
|
|
try_files $uri $uri/ /index.html; \n\
|
2022-01-08 19:26:11 +08:00
|
|
|
} \n\
|
|
|
|
\n\
|
|
|
|
location @rewrites { \n\
|
2022-01-30 00:19:55 +08:00
|
|
|
rewrite ^(.*)$ /index.html last; \n\
|
2022-01-08 19:26:11 +08:00
|
|
|
} \n\
|
|
|
|
\n\
|
|
|
|
location /api/ { \n\
|
2022-01-30 00:19:55 +08:00
|
|
|
proxy_set_header Host $host; \n\
|
|
|
|
proxy_set_header X-Real-IP $remote_addr; \n\
|
|
|
|
proxy_set_header X-Forwarded-For $remote_addr; \n\
|
|
|
|
proxy_set_header X-Forwarded-Host $remote_addr; \n\
|
|
|
|
proxy_set_header X-NginX-Proxy true; \n\
|
|
|
|
proxy_pass http://localhost:3000/; \n\
|
2022-01-08 19:26:11 +08:00
|
|
|
} \n\
|
2022-01-30 00:19:55 +08:00
|
|
|
}' > /etc/nginx/conf.d/default.conf
|
|
|
|
|
|
|
|
RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.14/main libuv \
|
|
|
|
&& apk add --no-cache --update-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.14/main nodejs npm \
|
|
|
|
&& npm i -g NeteaseCloudMusicApi
|
|
|
|
|
|
|
|
COPY --from=build /app/dist /usr/share/nginx/html
|
2022-01-08 19:26:11 +08:00
|
|
|
|
2022-01-30 00:19:55 +08:00
|
|
|
CMD nginx ; exec npx NeteaseCloudMusicApi
|