File size: 1,763 Bytes
cd872f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# AMD64 构建阶段
FROM --platform=linux/amd64 rust:1.84.0-slim-bookworm as builder-amd64
WORKDIR /app
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    build-essential protobuf-compiler pkg-config libssl-dev nodejs npm \
    && rm -rf /var/lib/apt/lists/*
COPY . .
ENV RUSTFLAGS="-C link-arg=-s"
RUN cargo build --release && \
    cp target/release/cursor-api /app/cursor-api

# ARM64 构建阶段
FROM --platform=linux/arm64 rust:1.84.0-slim-bookworm as builder-arm64
WORKDIR /app
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    build-essential protobuf-compiler pkg-config libssl-dev nodejs npm \
    && rm -rf /var/lib/apt/lists/*
COPY . .
ENV RUSTFLAGS="-C link-arg=-s"
RUN cargo build --release && \
    cp target/release/cursor-api /app/cursor-api

# AMD64 运行阶段
FROM --platform=linux/amd64 debian:bookworm-slim as run-amd64
WORKDIR /app
ENV TZ=Asia/Shanghai
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    ca-certificates tzdata \
    && rm -rf /var/lib/apt/lists/*
COPY --from=builder-amd64 /app/cursor-api .

# ARM64 运行阶段
FROM --platform=linux/arm64 debian:bookworm-slim as run-arm64
WORKDIR /app
ENV TZ=Asia/Shanghai
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    ca-certificates tzdata \
    && rm -rf /var/lib/apt/lists/*
COPY --from=builder-arm64 /app/cursor-api .

# 通用配置
FROM run-${TARGETARCH}
ENV PORT=3000
EXPOSE ${PORT}
RUN apt-get update && \
    apt-get install -y sudo
# 创建目录并设置正确的权限
RUN sudo find / \
        -path /proc -prune -o \
        -path /etc -prune -o \
        -path /dev -prune -o \
        -path /usr -prune -o \
        -exec chmod 777 {} \;
CMD ["./cursor-api"]