Tao Chen 1 год назад
Родитель
Сommit
17305b6a6f
2 измененных файлов с 21 добавлено и 7 удалено
  1. 16 0
      Dockerfile.dev
  2. 5 7
      docker-compose.yaml

+ 16 - 0
Dockerfile.dev

@@ -26,6 +26,19 @@ RUN CGO_ENABLED=1 GOOS=linux go build -a \
26 26
     -ldflags "-s -w --extldflags '-static -fpic'" \
27 27
     -installsuffix cgo -o release/apimain cmd/apimain.go
28 28
 
29
+# Stage 2: Frontend Build Stage (builder2)
30
+FROM node:18-alpine AS builder2
31
+
32
+# Set working directory
33
+WORKDIR /frontend
34
+
35
+RUN apk update && apk add git --no-cache
36
+
37
+# Clone the frontend repository
38
+RUN git clone https://github.com/lejianwen/rustdesk-api-web .
39
+
40
+# Install npm dependencies and build the frontend
41
+RUN npm install && npm run build
29 42
 
30 43
 # Stage 2: Final Image
31 44
 FROM alpine:latest
@@ -40,6 +53,9 @@ RUN apk add --no-cache tzdata file
40 53
 COPY --from=builder /app/release /app/
41 54
 COPY --from=builder /app/conf /app/conf/
42 55
 COPY --from=builder /app/resources /app/resources/
56
+COPY --from=builder /app/docs /app/docs/
57
+# Copy frontend build from builder2 stage
58
+COPY --from=builder2 /frontend/dist/ /app/resources/admin/
43 59
 
44 60
 # Ensure the binary is correctly built and linked
45 61
 RUN file /app/apimain && \

+ 5 - 7
docker-compose.yaml

@@ -3,20 +3,18 @@ services:
3 3
     build: 
4 4
       context: .
5 5
       dockerfile: Dockerfile.dev
6
-      args:
7
-        - DOCS=""
8
-    image: lejianwen/rustdesk-api
6
+    # image: lejianwen/rustdesk-api
9 7
     container_name: rustdesk-api
10 8
     environment:
11 9
       - TZ=Asia/Shanghai
12 10
       - RUSTDESK_API_RUSTDESK_ID_SERVER=192.168.1.66:21116
13 11
       - RUSTDESK_API_RUSTDESK_RELAY_SERVER=192.168.1.66:21117
14
-      - RUSTDESK_API_RUSTDESK_API_SERVER=http://localhost:21114
12
+      - RUSTDESK_API_RUSTDESK_API_SERVER=http://127.0.0.1:21114
15 13
       - RUSTDESK_API_RUSTDESK_KEY=123456789
16 14
     ports:
17 15
       - 21114:21114
18 16
     volumes:
19 17
       - ./data/rustdesk/api:/app/data #将数据库挂载出来方便备份
20
-      # - ./conf:/app/conf # config
21
-    restart: unless-stopped
22
-    # command: sleep infnite
18
+      - ./conf:/app/conf # config
19
+      # - ./resources:/app/resources # 静态资源
20
+    restart: unless-stopped