# EasyRemote Server Dockerfile
# 用于构建 Linux 版本的服务端

# 构建阶段
FROM rust:1.75-bookworm as builder

WORKDIR /app

# 复制项目文件
COPY . .

# 构建服务端
RUN cargo build --release --package easyremote-server

# 运行阶段
FROM debian:bookworm-slim

RUN apt-get update && apt-get install -y \
    ca-certificates \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# 从构建阶段复制可执行文件
COPY --from=builder /app/target/release/easyremote-server .
COPY --from=builder /app/crates/server/static ./static

# 创建数据目录
RUN mkdir -p /app/data

# 暴露端口
EXPOSE 8080
EXPOSE 3478/udp
EXPOSE 3479/udp

# 环境变量
ENV RUST_LOG=info
ENV DATABASE_URL=sqlite:///app/data/easyremote.db

# 启动服务
CMD ["./easyremote-server"]
