添加docker

This commit is contained in:
克洛伊尔 2024-11-01 15:23:25 +08:00
parent 9f88284bdf
commit 3119616c60
3 changed files with 37 additions and 1 deletions

13
.dockerignore Normal file
View File

@ -0,0 +1,13 @@
# 忽略 .git 目录
.git
.gitignore
pnpm-lock.yaml
dist/
# 忽略应设置为容器卷的东西
db/
# 忽略 node_modules 目录,因为它可以基于 package.json 重新生成
node_modules/

21
DOCKERFILE Normal file
View File

@ -0,0 +1,21 @@
# 使用官方 Node.js 20.18.0 版本的 slim 镜像作为基础镜像
FROM node:20.18.0
# 安装 Deno
RUN curl -fsSL https://x.deno.js.cn/install.sh | sh
# 将 Deno 的可执行文件路径添加到 PATH 环境变量中
ENV DENO_INSTALL="/root/.deno"
ENV PATH="$DENO_INSTALL/bin:$PATH"
# 设置工作目录
WORKDIR /app
# 将本地文件复制到容器中
COPY . .
RUN npm config set registry https://registry.npmmirror.com
RUN npm install
# 运行您的应用
CMD ["npm", "run", "dev"]

View File

@ -9,7 +9,9 @@
"test": "/root/.deno/bin/deno run -A ./src/index.js", "test": "/root/.deno/bin/deno run -A ./src/index.js",
"nodemon": "deno run -A --watch src/index.ts", "nodemon": "deno run -A --watch src/index.ts",
"build:linux": "deno compile --no-check -o dist/test --target x86_64-unknown-linux-gnu -A src/index.ts", "build:linux": "deno compile --no-check -o dist/test --target x86_64-unknown-linux-gnu -A src/index.ts",
"build:win": "deno compile --no-check -o dist/test --target x86_64-pc-windows-msvc -A src/index.ts" "build:win": "deno compile --no-check -o dist/test --target x86_64-pc-windows-msvc -A src/index.ts",
"docker": "docker build -t qqbot-image .",
"docker:run": "docker run -d --rm --name qqbot-image-app -v ./db:/app/db qqbot-image"
}, },
"author": "mine123456@foxmail.com", "author": "mine123456@foxmail.com",
"license": "ISC", "license": "ISC",