blue-blue commited on
Commit
3e43329
·
verified ·
1 Parent(s): b4c9d1f

Upload 2 files

Browse files
Files changed (2) hide show
  1. Dockerfile.txt +38 -0
  2. docker-compose.yml +84 -0
Dockerfile.txt ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM oven/bun:latest AS builder
2
+
3
+ WORKDIR /build
4
+ COPY web/package.json .
5
+ COPY web/bun.lock .
6
+ RUN bun install
7
+ COPY ./web .
8
+ COPY ./VERSION .
9
+ RUN DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(cat VERSION) bun run build
10
+
11
+ FROM golang:alpine AS builder2
12
+ ENV GO111MODULE=on CGO_ENABLED=0
13
+
14
+ ARG TARGETOS
15
+ ARG TARGETARCH
16
+ ENV GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64}
17
+ ENV GOEXPERIMENT=greenteagc
18
+
19
+ WORKDIR /build
20
+
21
+ ADD go.mod go.sum ./
22
+ RUN go mod download
23
+
24
+ COPY . .
25
+ COPY --from=builder /build/dist ./web/dist
26
+ RUN go build -ldflags "-s -w -X 'github.com/QuantumNous/new-api/common.Version=$(cat VERSION)'" -o new-api
27
+
28
+ FROM debian:bookworm-slim
29
+
30
+ RUN apt-get update \
31
+ && apt-get install -y --no-install-recommends ca-certificates tzdata libasan8 wget \
32
+ && rm -rf /var/lib/apt/lists/* \
33
+ && update-ca-certificates
34
+
35
+ COPY --from=builder2 /build/new-api /
36
+ EXPOSE 3000
37
+ WORKDIR /data
38
+ ENTRYPOINT ["/new-api"]
docker-compose.yml ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # New-API Docker Compose Configuration
2
+ #
3
+ # Quick Start:
4
+ # 1. docker-compose up -d
5
+ # 2. Access at http://localhost:3000
6
+ #
7
+ # Using MySQL instead of PostgreSQL:
8
+ # 1. Comment out the postgres service and SQL_DSN line 15
9
+ # 2. Uncomment the mysql service and SQL_DSN line 16
10
+ # 3. Uncomment mysql in depends_on (line 28)
11
+ # 4. Uncomment mysql_data in volumes section (line 64)
12
+ #
13
+ # ⚠️ IMPORTANT: Change all default passwords before deploying to production!
14
+
15
+ version: '3.4' # For compatibility with older Docker versions
16
+
17
+ services:
18
+ new-api:
19
+ image: calciumion/new-api:latest
20
+ container_name: new-api
21
+ restart: always
22
+ command: --log-dir /app/logs
23
+ ports:
24
+ - "3000:3000"
25
+ volumes:
26
+ - ./data:/data
27
+ - ./logs:/app/logs
28
+ environment:
29
+ - SQL_DSN=postgresql://root:123456@postgres:5432/new-api # ⚠️ IMPORTANT: Change the password in production!
30
+ # - SQL_DSN=root:123456@tcp(mysql:3306)/new-api # Point to the mysql service, uncomment if using MySQL
31
+ - REDIS_CONN_STRING=redis://redis
32
+ - TZ=Asia/Shanghai
33
+ - ERROR_LOG_ENABLED=true # 是否启用错误日志记录 (Whether to enable error log recording)
34
+ - BATCH_UPDATE_ENABLED=true # 是否启用批量更新 (Whether to enable batch update)
35
+ # - STREAMING_TIMEOUT=300 # 流模式无响应超时时间,单位秒,默认120秒,如果出现空补全可以尝试改为更大值 (Streaming timeout in seconds, default is 120s. Increase if experiencing empty completions)
36
+ # - SESSION_SECRET=random_string # 多机部署时设置,必须修改这个随机字符串!! (multi-node deployment, set this to a random string!!!!!!!)
37
+ # - SYNC_FREQUENCY=60 # Uncomment if regular database syncing is needed
38
+ # - GOOGLE_ANALYTICS_ID=G-XXXXXXXXXX # Google Analytics 的测量 ID (Google Analytics Measurement ID)
39
+ # - UMAMI_WEBSITE_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx # Umami 网站 ID (Umami Website ID)
40
+ # - UMAMI_SCRIPT_URL=https://analytics.umami.is/script.js # Umami 脚本 URL,默认为官方地址 (Umami Script URL, defaults to official URL)
41
+
42
+ depends_on:
43
+ - redis
44
+ - postgres
45
+ # - mysql # Uncomment if using MySQL
46
+ healthcheck:
47
+ test: ["CMD-SHELL", "wget -q -O - http://localhost:3000/api/status | grep -o '\"success\":\\s*true' || exit 1"]
48
+ interval: 30s
49
+ timeout: 10s
50
+ retries: 3
51
+
52
+ redis:
53
+ image: redis:latest
54
+ container_name: redis
55
+ restart: always
56
+
57
+ postgres:
58
+ image: postgres:15
59
+ container_name: postgres
60
+ restart: always
61
+ environment:
62
+ POSTGRES_USER: root
63
+ POSTGRES_PASSWORD: 123456 # ⚠️ IMPORTANT: Change this password in production!
64
+ POSTGRES_DB: new-api
65
+ volumes:
66
+ - pg_data:/var/lib/postgresql/data
67
+ # ports:
68
+ # - "5432:5432" # Uncomment if you need to access PostgreSQL from outside Docker
69
+
70
+ # mysql:
71
+ # image: mysql:8.2
72
+ # container_name: mysql
73
+ # restart: always
74
+ # environment:
75
+ # MYSQL_ROOT_PASSWORD: 123456 # ⚠️ IMPORTANT: Change this password in production!
76
+ # MYSQL_DATABASE: new-api
77
+ # volumes:
78
+ # - mysql_data:/var/lib/mysql
79
+ # ports:
80
+ # - "3306:3306" # Uncomment if you need to access MySQL from outside Docker
81
+
82
+ volumes:
83
+ pg_data:
84
+ # mysql_data: