初次提交
This commit is contained in:
39
backend/Dockerfile.executable
Normal file
39
backend/Dockerfile.executable
Normal file
@@ -0,0 +1,39 @@
|
||||
# 最小化运行环境 - 使用可执行文件
|
||||
FROM alpine:latest
|
||||
|
||||
# 安装运行时依赖
|
||||
RUN apk add --no-cache \
|
||||
curl \
|
||||
tzdata \
|
||||
ca-certificates \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
# 设置时区
|
||||
ENV TZ=Asia/Shanghai
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
# 创建应用用户
|
||||
RUN adduser -D -s /bin/sh app
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 复制可执行文件
|
||||
COPY dist/cloud-drive-server /app/cloud-drive-server
|
||||
|
||||
# 创建必要的目录
|
||||
RUN mkdir -p /app/uploads /app/logs \
|
||||
&& chown -R app:app /app
|
||||
|
||||
# 切换到非root用户
|
||||
USER app
|
||||
|
||||
# 暴露端口
|
||||
EXPOSE 8002
|
||||
|
||||
# 健康检查
|
||||
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:8002/api/v1/health || exit 1
|
||||
|
||||
# 启动命令
|
||||
CMD ["./cloud-drive-server"]
|
||||
Reference in New Issue
Block a user