feat: add docker image

This commit is contained in:
zaunist committed 2025-06-26 17:14:17 +08:00
1 parent 76e8c1047b
commit 2d0cb02f6c
11 files changed
+7958 -11034

No files matched your search

+69
View File
@@ -0,0 +1,69 @@
# Node modules
node_modules
frontend/node_modules
backend/node_modules
package-lock.json
frontend/package-lock.json
backend/package-lock.json
# Build outputs
frontend/dist
backend/dist
.wrangler
# Environment files
.env
.env.local
.env.*.local
# Logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Coverage directory used by tools like istanbul
coverage
# IDE files
.vscode
.idea
*.swp
*.swo
# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Git
.git
.gitignore
# Docker
Dockerfile
.dockerignore
# Documentation
README.md
README_EN.md
LICENSE
# CI/CD
.github
# Trae AI
.trae
# Agent (Go binary)
agent/agent
+34
View File
@@ -0,0 +1,34 @@
name: Docker image build
on:
push:
branches:
- 'main'
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: zaunist/xugou:latest
+39
View File
@@ -0,0 +1,39 @@
# 使用 Node.js 20 作为基础镜像
FROM node:20
# 安装 cron 和 curl
RUN apt-get update && apt-get install -y cron curl && rm -rf /var/lib/apt/lists/*
# 安装 pnpm
RUN npm install -g pnpm
# 设置工作目录
WORKDIR /app
# 复制源代码
COPY . .
# 清理可能存在的依赖文件
RUN rm -rf node_modules bun.lockb frontend/node_modules backend/node_modules
# 安装依赖
RUN pnpm install
RUN pnpm run build
# 创建 crontab 文件
RUN echo '* * * * * curl "http://localhost:8080/__scheduled?cron=*+*+*+*+*" > /proc/1/fd/1 2>&1' | crontab -
# 创建启动脚本
RUN echo '#!/bin/sh' > /start.sh && \
echo 'echo "Starting cron daemon..."' >> /start.sh && \
echo 'service cron start' >> /start.sh && \
echo 'echo "Starting application..."' >> /start.sh && \
echo 'pnpm run preview' >> /start.sh && \
chmod +x /start.sh
# 暴露端口
EXPOSE 8080
# 启动服务
CMD ["/start.sh"]
-3011
View File
File diff suppressed because it is too large. Load diff
+6 -5
View File
@@ -4,8 +4,8 @@
"main": "dist/index.js",
"type": "module",
"scripts": {
"dev": "wrangler dev --test-scheduled",
"build": "tsc && npm run generate:migrations",
"dev": "wrangler dev --test-scheduled --ip 0.0.0.0 --port 8080",
"build": "tsc && pnpm run generate:migrations",
"deploy": "wrangler deploy",
"db:generate": "drizzle-kit generate",
"generate:migrations": "tsx scripts/generate-migrations.ts"
@@ -21,15 +21,16 @@
"@types/node": "^22.13.10",
"bcryptjs": "^2.4.3",
"dotenv": "^16.5.0",
"drizzle-orm": "^0.44.1",
"drizzle-orm": "^0.44.2",
"hono": "^4.7.4",
"jsonwebtoken": "^9.0.2",
"typescript": "^5.8.2"
"typescript": "^5.8.2",
"zod": "^3.22.4"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20250317.0",
"cross-env": "^7.0.3",
"drizzle-kit": "^0.31.1",
"drizzle-kit": "^0.31.2",
"nodemon": "^3.1.9",
"ts-node": "^10.9.2",
"tsx": "^4.19.4",
+23
View File
@@ -0,0 +1,23 @@
version: '3.8'
services:
xugou-app:
image: zaunist/xugou:latest
ports:
- "8080:8080"
environment:
- NODE_ENV=production
volumes:
# 挂载 .wrangler 目录用于数据持久化(SQLite 数据库文件)
- wrangler_data:/app/.wrangler
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
volumes:
wrangler_data:
driver: local
-8004
View File
File diff suppressed because it is too large. Load diff
+8 -11
View File
@@ -3,18 +3,15 @@
"version": "1.0.0",
"description": "Xugou monitoring system",
"private": true,
"workspaces": [
"frontend",
"backend"
],
"scripts": {
"dev:frontend": "npm run dev --workspace=frontend",
"dev:backend": "npm run dev --workspace=backend",
"build:frontend": "npm run build --workspace=frontend",
"build:backend": "npm run build --workspace=backend",
"db:generate": "npm run db:generate --workspace=backend",
"build": "npm run db:generate && npm run build:frontend && npm run build:backend",
"dev:frontend": "cd frontend && pnpm run dev",
"dev:backend": "cd backend && pnpm run dev",
"build:frontend": "cd frontend && pnpm run build",
"build:backend": "cd backend && pnpm run build",
"generate": "cd backend && pnpm run db:generate",
"build": "pnpm run generate && pnpm run build:frontend && pnpm run build:backend",
"deploy": "wrangler deploy",
"preview": "npm run build && npm run dev --workspace=backend"
"dev:preview": "pnpm run build && cd backend && pnpm run dev",
"preview": "cd backend && pnpm run dev"
}
}
+7776
View File
File diff suppressed because it is too large. Load diff
+3
View File
@@ -0,0 +1,3 @@
packages:
- 'frontend'
- 'backend'
-3
View File
@@ -19,9 +19,6 @@ binding = "DB"
database_name = "xugou_db"
database_id = "32a2ca5f-3a77-4b08-965e-804612557880"
[build]
command = "npm run build"
[assets]
binding = "ASSETS"
directory = "frontend/dist"