From 66f9b4f526f9e4a03496762833dfb3b7688ae0bd Mon Sep 17 00:00:00 2001 From: Rick Date: Sat, 8 Jan 2022 19:26:11 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=94=AF=E6=8C=81=20Docker=20?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=20(#1195)=20(#1200)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 16 ++++++++++++++++ Dockerfile | 42 ++++++++++++++++++++++++++++++++++++++++++ README.md | 22 ++++++++++++++++++++++ docker-compose.yml | 9 +++++++++ 4 files changed, 89 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..03f2450 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,16 @@ +node_modules +npm-debug.log +Dockerfile* +docker-compose* +.dockerignore +.git +.github +.gitignore +README.md +LICENSE +.vscode +dist +dist_electron +build +images +script \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..58128ce --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +FROM node:lts-alpine as build +ENV VUE_APP_NETEASE_API_URL=/api +WORKDIR /app +COPY . . +RUN yarn && yarn build + +FROM nginx:alpine as app +COPY --from=build /app/dist /usr/share/nginx/html +COPY --from=build /app/netease_api /usr/src/netease_api +WORKDIR /usr/src/netease_api + +RUN apk add --no-cache --repository http://nl.alpinelinux.org/alpine/edge/main libuv \ + && apk add --no-cache --update-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/main nodejs=16.13.1-r1 npm=8.3.0-r0 \ + && npm install + +RUN echo $'server { \n\ + gzip on;\n\ + listen 80; \n\ + listen [::]:80; \n\ + server_name localhost; \n\ + \n\ + location / { \n\ + root /usr/share/nginx/html; \n\ + index index.html; \n\ + try_files $uri $uri/ /index.html; \n\ + } \n\ + \n\ + location @rewrites { \n\ + rewrite ^(.*)$ /index.html last; \n\ + } \n\ + \n\ + location /api/ { \n\ + 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\ + } \n\ +}' > /etc/nginx/conf.d/default.conf + +CMD nginx ; exec node app.js \ No newline at end of file diff --git a/README.md b/README.md index 548dcc5..2f8c92c 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,28 @@ yarn run build 7. 将 `/dist` 目录下的文件上传到你的 Web 服务器 +## ⚙️ Docker 部署 + +1. 构建 Docker Image + +```sh +docker build -t yesplaymusic . +``` + +2. 启动 Docker Container + +```sh +docker run -d --name YesPlayMusic -p 80:80 yesplaymusic +``` + +3. Docker Compose 启动 + +```sh +docker-compose up -d +``` + +YesPlayMusic 地址为 `http://localhost` + ## 👷‍♂️ 打包客户端 如果在 Release 页面没有找到适合你的设备的安装包的话,你可以根据下面的步骤来打包自己的客户端。 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..efc2826 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +services: + YesPlayMusic: + build: + context: . + image: yesplaymusic + container_name: YesPlayMusic + ports: + - 80:80 + restart: always