feat: refactor Dockerfile and implement new CSV handling logic

This commit is contained in:
wood 2024-09-12 16:44:26 +08:00
parent 0aaed93abc
commit 4367782a36
3 changed files with 17 additions and 3 deletions

View File

@ -24,6 +24,8 @@ WORKDIR /root/
COPY --from=builder /app/random-api .
COPY --from=builder /app/public ./public
# 复制 public 目录到一个临时位置
COPY --from=builder /app/public /tmp/public
# 创建日志目录并设置权限
RUN mkdir -p /var/log/random-api && chmod 755 /var/log/random-api
@ -34,5 +36,8 @@ EXPOSE 5003
RUN apk add --no-cache tini
ENTRYPOINT ["/sbin/tini", "--"]
# 运行应用
CMD ["./random-api"]
# 创建一个启动脚本
COPY start.sh /start.sh
RUN chmod +x /start.sh
CMD ["/start.sh"]

View File

@ -8,4 +8,4 @@ services:
- ./logs:/var/log/random-api
environment:
- TZ=Asia/Shanghai
restart: unless-stopped
restart: unless-stopped

9
start.sh Normal file
View File

@ -0,0 +1,9 @@
#!/bin/sh
# 如果挂载的 public 目录为空,则从临时位置复制文件
if [ ! "$(ls -A /root/public)" ]; then
cp -r /tmp/public/* /root/public/
fi
# 启动应用
./random-api