Skip to content

Commit 697a48d

Browse files
committed
fixbug: 处理换行问题导致 windows 上构建无法找到docker-entrypoint.sh脚本问题
1 parent 6174bf0 commit 697a48d

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

.gitattributes

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# 默认文本文件按 LF 存储
2+
* text=auto eol=lf
3+
4+
# 关键脚本/配置强制 LF
5+
*.sh text eol=lf
6+
Dockerfile text eol=lf
7+
*.yml text eol=lf
8+
*.yaml text eol=lf
9+
*.py text eol=lf
10+
*.md text eol=lf
11+
12+
# Windows 脚本
13+
*.bat text eol=crlf
14+
*.cmd text eol=crlf

Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ RUN pip install --no-cache-dir -r requirements.txt
2222
# 复制项目代码
2323
COPY . .
2424

25-
# 确保脚本具有执行权限
26-
RUN chmod +x scripts/sync_stars.py
27-
RUN chmod +x docker-entrypoint.sh
25+
# 确保脚本具有执行权限,并消除可能的 CRLF 换行问题
26+
RUN chmod +x /app/scripts/sync_stars.py \
27+
&& sed -i 's/\r$//' /app/docker-entrypoint.sh \
28+
&& chmod +x /app/docker-entrypoint.sh
2829

2930
# 暴露端口(虽然 sync 主要是后台脚本,但为了统一性声明)
3031
# HTML 展示由单独的 Nginx 处理,这里不强制暴露端口
3132

32-
ENTRYPOINT ["/app/docker-entrypoint.sh"]
33+
ENTRYPOINT ["/bin/sh", "/app/docker-entrypoint.sh"]

docker-entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/sh
22
# docker-entrypoint.sh
33

44
set -e

0 commit comments

Comments
 (0)