forked from waterwoodwind/cursor-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
48 lines (36 loc) · 936 Bytes
/
Dockerfile
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
# 构建阶段
FROM rust:1.83.0-slim-bookworm as builder
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 . .
# 构建
RUN rustup target add x86_64-unknown-linux-gnu && \
cargo build --target x86_64-unknown-linux-gnu --release && \
cp target/x86_64-unknown-linux-gnu/release/cursor-api /app/cursor-api
# 运行阶段
FROM debian:bookworm-slim
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 /app/cursor-api .
# 设置默认端口
ENV PORT=3000
# 动态暴露端口
EXPOSE ${PORT}
CMD ["./cursor-api"]