From 4cb8eb0213e7d302779d15d793b54920b01cedce Mon Sep 17 00:00:00 2001 From: imsyy Date: Wed, 20 Dec 2023 14:40:39 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E6=94=AF=E6=8C=81=20Docker?= =?UTF-8?q?=20=E9=83=A8=E7=BD=B2=20#82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 12 ++++ .npmrc | 5 +- Dockerfile | 29 +++++++++ README.md | 27 ++++++++ auto-imports.d.ts | 123 +++++++++++++++++------------------- docker-compose.yml | 12 ++++ nginx.conf | 28 ++++++++ src/views/Like/index.vue | 63 ++++++++++++++++++ src/views/Setting/index.vue | 2 +- 9 files changed, 233 insertions(+), 68 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 nginx.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..4ee667eb --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +node_modules +npm-debug.log +Dockerfile* +docker-compose* +.dockerignore +.git +.github +.gitignore +README.md +LICENSE +.vscode +dist diff --git a/.npmrc b/.npmrc index 9f2422a6..43fbaed1 100644 --- a/.npmrc +++ b/.npmrc @@ -1,2 +1,5 @@ -ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/ +registry=https://registry.npmmirror.com +disturl=https://registry.npmmirror.com/-/binary/node +# ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/ +ELECTRON_MIRROR=https://registry.npmmirror.com/-/binary/electron/ shamefully-hoist=true diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..dc4d38b0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +# build +FROM node:18-alpine as builder + +RUN apk update && apk add --no-cache git + +WORKDIR /app + +COPY package*.json ./ + +RUN npm install + +COPY . . + +RUN [ ! -e ".env" ] && cp .env.example .env || true + +RUN npm run build + +# nginx +FROM nginx:1.20.2-alpine as app + +COPY --from=builder /app/out/renderer /usr/share/nginx/html + +COPY --from=builder /app/nginx.conf /etc/nginx/conf.d/default.conf + +RUN apk add --no-cache npm + +RUN npm install -g NeteaseCloudMusicApi + +CMD nginx && npx NeteaseCloudMusicApi diff --git a/README.md b/README.md index cc1a23c7..c2b43c29 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,33 @@ [Dev Workflow](https://github.com/imsyy/SPlayer/actions/workflows/build.yml) +## ⚙️ Docker 部署 + +> 安装及配置 `Docker` 将不在此处说明,请自行解决 + +### 本地构建 + +```bash +# 构建 +docker build -t splayer . + +# 运行 +docker run -d --name SPlayer -p 7899:7899 splayer +# 或使用 Docker Compose +docker-compose up -d +``` + +### 在线部署 + +```bash +# 拉取 +docker pull imsyy/splayer:2.0.0-beta.5 +# 运行 +docker run -d --name SPlayer -p 7899:7899 imsyy/splayer:2.0.0-beta.5 +``` + +以上步骤成功后,将会在本地 [localhost:7899](http://localhost:7899/) 启动,如需更换端口,请自行修改命令行中的端口号 + ## ⚙️ Vercel 部署 > 其他部署平台大致相同,在此不做说明 diff --git a/auto-imports.d.ts b/auto-imports.d.ts index c5b8cec9..61d55710 100644 --- a/auto-imports.d.ts +++ b/auto-imports.d.ts @@ -5,74 +5,65 @@ // Generated by unplugin-auto-import export {} declare global { - const EffectScope: (typeof import("vue"))["EffectScope"]; - const computed: (typeof import("vue"))["computed"]; - const createApp: (typeof import("vue"))["createApp"]; - const customRef: (typeof import("vue"))["customRef"]; - const defineAsyncComponent: (typeof import("vue"))["defineAsyncComponent"]; - const defineComponent: (typeof import("vue"))["defineComponent"]; - const effectScope: (typeof import("vue"))["effectScope"]; - const getCurrentInstance: (typeof import("vue"))["getCurrentInstance"]; - const getCurrentScope: (typeof import("vue"))["getCurrentScope"]; - const h: (typeof import("vue"))["h"]; - const inject: (typeof import("vue"))["inject"]; - const isProxy: (typeof import("vue"))["isProxy"]; - const isReactive: (typeof import("vue"))["isReactive"]; - const isReadonly: (typeof import("vue"))["isReadonly"]; - const isRef: (typeof import("vue"))["isRef"]; - const markRaw: (typeof import("vue"))["markRaw"]; - const nextTick: (typeof import("vue"))["nextTick"]; - const onActivated: (typeof import("vue"))["onActivated"]; - const onBeforeMount: (typeof import("vue"))["onBeforeMount"]; - const onBeforeUnmount: (typeof import("vue"))["onBeforeUnmount"]; - const onBeforeUpdate: (typeof import("vue"))["onBeforeUpdate"]; - const onDeactivated: (typeof import("vue"))["onDeactivated"]; - const onErrorCaptured: (typeof import("vue"))["onErrorCaptured"]; - const onMounted: (typeof import("vue"))["onMounted"]; - const onRenderTracked: (typeof import("vue"))["onRenderTracked"]; - const onRenderTriggered: (typeof import("vue"))["onRenderTriggered"]; - const onScopeDispose: (typeof import("vue"))["onScopeDispose"]; - const onServerPrefetch: (typeof import("vue"))["onServerPrefetch"]; - const onUnmounted: (typeof import("vue"))["onUnmounted"]; - const onUpdated: (typeof import("vue"))["onUpdated"]; - const provide: (typeof import("vue"))["provide"]; - const reactive: (typeof import("vue"))["reactive"]; - const readonly: (typeof import("vue"))["readonly"]; - const ref: (typeof import("vue"))["ref"]; - const resolveComponent: (typeof import("vue"))["resolveComponent"]; - const shallowReactive: (typeof import("vue"))["shallowReactive"]; - const shallowReadonly: (typeof import("vue"))["shallowReadonly"]; - const shallowRef: (typeof import("vue"))["shallowRef"]; - const toRaw: (typeof import("vue"))["toRaw"]; - const toRef: (typeof import("vue"))["toRef"]; - const toRefs: (typeof import("vue"))["toRefs"]; - const toValue: (typeof import("vue"))["toValue"]; - const triggerRef: (typeof import("vue"))["triggerRef"]; - const unref: (typeof import("vue"))["unref"]; - const useAttrs: (typeof import("vue"))["useAttrs"]; - const useCssModule: (typeof import("vue"))["useCssModule"]; - const useCssVars: (typeof import("vue"))["useCssVars"]; - const useDialog: (typeof import("naive-ui"))["useDialog"]; - const useLoadingBar: (typeof import("naive-ui"))["useLoadingBar"]; - const useMessage: (typeof import("naive-ui"))["useMessage"]; - const useNotification: (typeof import("naive-ui"))["useNotification"]; - const useSlots: (typeof import("vue"))["useSlots"]; - const watch: (typeof import("vue"))["watch"]; - const watchEffect: (typeof import("vue"))["watchEffect"]; - const watchPostEffect: (typeof import("vue"))["watchPostEffect"]; - const watchSyncEffect: (typeof import("vue"))["watchSyncEffect"]; + const EffectScope: typeof import('vue')['EffectScope'] + const computed: typeof import('vue')['computed'] + const createApp: typeof import('vue')['createApp'] + const customRef: typeof import('vue')['customRef'] + const defineAsyncComponent: typeof import('vue')['defineAsyncComponent'] + const defineComponent: typeof import('vue')['defineComponent'] + const effectScope: typeof import('vue')['effectScope'] + const getCurrentInstance: typeof import('vue')['getCurrentInstance'] + const getCurrentScope: typeof import('vue')['getCurrentScope'] + const h: typeof import('vue')['h'] + const inject: typeof import('vue')['inject'] + const isProxy: typeof import('vue')['isProxy'] + const isReactive: typeof import('vue')['isReactive'] + const isReadonly: typeof import('vue')['isReadonly'] + const isRef: typeof import('vue')['isRef'] + const markRaw: typeof import('vue')['markRaw'] + const nextTick: typeof import('vue')['nextTick'] + const onActivated: typeof import('vue')['onActivated'] + const onBeforeMount: typeof import('vue')['onBeforeMount'] + const onBeforeUnmount: typeof import('vue')['onBeforeUnmount'] + const onBeforeUpdate: typeof import('vue')['onBeforeUpdate'] + const onDeactivated: typeof import('vue')['onDeactivated'] + const onErrorCaptured: typeof import('vue')['onErrorCaptured'] + const onMounted: typeof import('vue')['onMounted'] + const onRenderTracked: typeof import('vue')['onRenderTracked'] + const onRenderTriggered: typeof import('vue')['onRenderTriggered'] + const onScopeDispose: typeof import('vue')['onScopeDispose'] + const onServerPrefetch: typeof import('vue')['onServerPrefetch'] + const onUnmounted: typeof import('vue')['onUnmounted'] + const onUpdated: typeof import('vue')['onUpdated'] + const provide: typeof import('vue')['provide'] + const reactive: typeof import('vue')['reactive'] + const readonly: typeof import('vue')['readonly'] + const ref: typeof import('vue')['ref'] + const resolveComponent: typeof import('vue')['resolveComponent'] + const shallowReactive: typeof import('vue')['shallowReactive'] + const shallowReadonly: typeof import('vue')['shallowReadonly'] + const shallowRef: typeof import('vue')['shallowRef'] + const toRaw: typeof import('vue')['toRaw'] + const toRef: typeof import('vue')['toRef'] + const toRefs: typeof import('vue')['toRefs'] + const toValue: typeof import('vue')['toValue'] + const triggerRef: typeof import('vue')['triggerRef'] + const unref: typeof import('vue')['unref'] + const useAttrs: typeof import('vue')['useAttrs'] + const useCssModule: typeof import('vue')['useCssModule'] + const useCssVars: typeof import('vue')['useCssVars'] + const useDialog: typeof import('naive-ui')['useDialog'] + const useLoadingBar: typeof import('naive-ui')['useLoadingBar'] + const useMessage: typeof import('naive-ui')['useMessage'] + const useNotification: typeof import('naive-ui')['useNotification'] + const useSlots: typeof import('vue')['useSlots'] + const watch: typeof import('vue')['watch'] + const watchEffect: typeof import('vue')['watchEffect'] + const watchPostEffect: typeof import('vue')['watchPostEffect'] + const watchSyncEffect: typeof import('vue')['watchSyncEffect'] } // for type re-export declare global { // @ts-ignore - export type { - Component, - ComponentPublicInstance, - ComputedRef, - InjectionKey, - PropType, - Ref, - VNode, - WritableComputedRef, - } from "vue"; + export type { Component, ComponentPublicInstance, ComputedRef, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue' } diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..586ef566 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +services: + SPlayer: + build: + context: . + image: splayer + container_name: SPlayer + volumes: + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro + ports: + - 7899:7899 + restart: always diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 00000000..0cf056fa --- /dev/null +++ b/nginx.conf @@ -0,0 +1,28 @@ +server { + gzip on; + listen 7899; + listen [::]:7899; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html; + try_files $uri $uri/ /index.html; + } + + location @rewrites { + rewrite ^(.*)$ /index.html last; + } + + location /api/ { + proxy_buffers 16 32k; + proxy_buffer_size 128k; + proxy_busy_buffers_size 128k; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Host $remote_addr; + proxy_set_header X-NginX-Proxy true; + proxy_pass http://localhost:3000/; + } +} diff --git a/src/views/Like/index.vue b/src/views/Like/index.vue index 1f2d86d3..b440c84b 100644 --- a/src/views/Like/index.vue +++ b/src/views/Like/index.vue @@ -1,6 +1,41 @@