feat: Add Docker #107

This commit is contained in:
imsyy 2023-12-06 13:41:45 +08:00
parent 1e0fe3e724
commit b28f92b99f
8 changed files with 58 additions and 1 deletions

15
.dockerignore Normal file
View File

@ -0,0 +1,15 @@
node_modules
npm-debug.log
Dockerfile*
docker-compose*
.dockerignore
.git
.github
.gitignore
README.md
LICENSE
.vscode
dist
build
images
script

3
.eslintignore Normal file
View File

@ -0,0 +1,3 @@
node_modules
dist
.gitignore

16
Dockerfile Normal file
View File

@ -0,0 +1,16 @@
# 构建应用
FROM node:18 AS builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# 最小化镜像
FROM node:18-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
RUN npm install -g http-server
EXPOSE 12445
CMD ["http-server", "dist", "-p", "12445"]

View File

@ -65,6 +65,17 @@ pnpm build
``` ```
> 构建完成后,静态资源会在 **`dist` 目录** 中生成,可将 **`dist` 文件夹下的文件**上传至服务器,也可使用 `Vercel` 等托管平台一键导入并自动部署 > 构建完成后,静态资源会在 **`dist` 目录** 中生成,可将 **`dist` 文件夹下的文件**上传至服务器,也可使用 `Vercel` 等托管平台一键导入并自动部署
### Docker 部署
> 安装及配置 Docker 将不在此处说明,请自行解决
```bash
// 构建
docker build -t home .
// 运行
docker run -p 12445:12445 -d home
```
### 网站链接 ### 网站链接
`src/assets/siteLinks.json` 中可以自定义网站链接(以指向自己的网站): `src/assets/siteLinks.json` 中可以自定义网站链接(以指向自己的网站):

9
docker-compose.yml Normal file
View File

@ -0,0 +1,9 @@
version: '3'
services:
app:
build:
context: .
dockerfile: Dockerfile
ports:
- "12445:12445"

View File

@ -10,7 +10,8 @@
"dev": "vite --host", "dev": "vite --host",
"build": "vite build", "build": "vite build",
"preview": "vite preview", "preview": "vite preview",
"format": "prettier --write src/" "format": "prettier --write src/",
"lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts,.vue --fix"
}, },
"dependencies": { "dependencies": {
"aplayer": "^1.10.1", "aplayer": "^1.10.1",

View File

@ -13,6 +13,7 @@ export const getPlayerList = async (server, type, id) => {
const data = await res.json(); const data = await res.json();
if (data[0].url.startsWith("@")) { if (data[0].url.startsWith("@")) {
// eslint-disable-next-line no-unused-vars
const [handle, jsonpCallback, jsonpCallbackFunction, url] = data[0].url.split("@").slice(1); const [handle, jsonpCallback, jsonpCallbackFunction, url] = data[0].url.split("@").slice(1);
const jsonpData = await fetchJsonp(url).then((res) => res.json()); const jsonpData = await fetchJsonp(url).then((res) => res.json());
const domain = ( const domain = (

View File

@ -1,3 +1,4 @@
/* eslint-disable no-undef */
import { defineConfig, loadEnv } from "vite"; import { defineConfig, loadEnv } from "vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers"; import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import { resolve } from "path"; import { resolve } from "path";