RustDesk-API2 / Dockerfile
HuggingFace0920's picture
Update Dockerfile
0bd2cb4 verified
raw
history blame
1.1 kB
FROM golang:1.20-alpine AS builder
# 设置工作目录
WORKDIR /app
# 安装必要的依赖
RUN apk add --no-cache git make gcc musl-dev nodejs npm
# 克隆 RustDesk API 仓库
RUN git clone https://github.com/lejianwen/rustdesk-api.git .
# 安装 Go 依赖
RUN go mod tidy
# 构建前端
RUN mkdir -p resources/admin
RUN git clone https://github.com/lejianwen/rustdesk-api-web resources/rustdesk-api-web
WORKDIR /app/resources/rustdesk-api-web
RUN npm install
RUN npm run build
RUN cp -ar dist/* ../admin/
# 生成 API 代码
WORKDIR /app
RUN go generate generate_api.go
# 构建最终的可执行文件
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o rustdesk-api .
# 创建轻量级运行时镜像
FROM alpine:latest
# 安装必要的依赖
RUN apk --no-cache add ca-certificates
# 设置工作目录
WORKDIR /app
# 从构建镜像复制可执行文件
COPY --from=builder /app/rustdesk-api .
COPY --from=builder /app/resources /app/resources
COPY --from=builder /app/config.yaml /app/config.yaml
# 暴露 API 端口
EXPOSE 8080
# 启动应用
CMD ["./rustdesk-api"]