Skip to content

Commit ce96dfd

Browse files
committed
up
1 parent 045853b commit ce96dfd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+7223
-33
lines changed

.github/workflows/docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ jobs:
3232
with:
3333
context: .
3434
push: true
35-
platforms: linux/amd64,linux/arm64 # 指定多架构
35+
platforms: linux/amd64,linux/arm64,linux/386,linux/arm/v6,linux/arm/v7
3636
tags: cmliu/cfnat:latest

Dockerfile

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,43 @@
1-
FROM alpine:3.9
1+
# 第一个阶段用于根据架构复制文件
2+
FROM --platform=$TARGETPLATFORM alpine:3.19 AS builder
3+
4+
# 设置构建参数
5+
ARG TARGETPLATFORM
6+
ARG TARGETARCH
7+
8+
# 复制二进制文件 - 修改复制路径
9+
COPY /cfnat/* ./app/
10+
COPY /go.sh ./go.sh
11+
COPY /ips-v4.txt ./ips-v4.txt
12+
COPY /ips-v6.txt ./ips-v6.txt
13+
COPY /locations.json ./locations.json
14+
15+
# 添加调试信息
16+
RUN echo "Files in builder:" && ls -la
17+
18+
# 检查文件是否存在并根据目标架构重命名二进制文件
19+
RUN ls -la && \
20+
case "$TARGETARCH" in \
21+
amd64) mv ./app/cfnat-linux-amd64 ./cfnat ;; \
22+
386) mv ./app/cfnat-linux-386 ./cfnat ;; \
23+
arm64) mv ./app/cfnat-linux-arm64 ./cfnat ;; \
24+
arm/v5) mv ./app/cfnat-linux-armv5 ./cfnat ;; \
25+
arm/v6) mv ./app/cfnat-linux-armv6 ./cfnat ;; \
26+
arm/v7) mv ./app/cfnat-linux-armv7 ./cfnat ;; \
27+
esac
28+
29+
# 第二个阶段:运行阶段
30+
FROM --platform=$TARGETPLATFORM alpine:3.19
31+
32+
# 复制构建阶段的文件到运行阶段
33+
COPY --from=builder /cfnat ./cfnat
34+
COPY --from=builder /ips-v4.txt ./ips-v4.txt
35+
COPY --from=builder /ips-v6.txt ./ips-v6.txt
36+
COPY --from=builder /locations.json ./locations.json
37+
COPY --from=builder /go.sh ./go.sh
38+
39+
# 赋予可执行权限
40+
RUN chmod +x ./cfnat ./go.sh
241

342
# 设置环境变量默认值
443
ENV colo="SJC,LAX,HKG" \
@@ -12,22 +51,8 @@ ENV colo="SJC,LAX,HKG" \
1251
tls="true" \
1352
domain="cloudflaremirrors.com/debian"
1453

15-
# 复制相关文件到容器根目录
16-
COPY cfnat-linux-amd64 ./cfnat-linux-amd64
17-
COPY cfnat-linux-arm64 ./cfnat-linux-arm64
18-
COPY go.sh ./go.sh
19-
COPY ips-v4.txt ./ips-v4.txt
20-
COPY ips-v6.txt ./ips-v6.txt
21-
COPY locations.json ./locations.json
22-
23-
# 安装 bash,因为 Alpine 默认没有 bash
24-
RUN apk add --no-cache bash
25-
26-
# 赋予可执行权限
27-
RUN chmod +x ./cfnat-linux-amd64 ./cfnat-linux-arm64 ./go.sh
28-
2954
# 暴露 1234 端口
3055
EXPOSE 1234
3156

3257
# 运行 go.sh 脚本
33-
CMD ["/bin/bash", "./go.sh"]
58+
CMD ["/bin/sh", "./go.sh"]

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ docker run -d -e colo="HKG" -e delay=160 -e ips=6 -p 1234:1234 cmliu/cfnat:lates
1919
- IP类型(ips): 4
2020
- 转发端口(port): 80
2121
- tls: false
22-
- **本地映射端口: 80**
22+
- **本地映射端口: 8080**
2323
```shell
24-
docker run -d -e colo="HKG" -e delay=160 -e ips=4 -e port=80 -e tls=false -p 80:1234 cmliu/cfnat:latest
24+
docker run -d -e colo="HKG" -e delay=160 -e ips=4 -e port=80 -e tls=false -p 8080:1234 cmliu/cfnat:latest
2525
```
2626

2727
----
@@ -96,4 +96,7 @@ docker exec 容器ID cat cfnat.log
9696
是否为 TLS 端口 (default true)
9797
-task int
9898
最大并发请求数: 并发请求最大协程数 (default 100)
99-
```
99+
```
100+
101+
# 致谢
102+
[gdfsnhsw](https://github.com/gdfsnhsw/CFnat-Docker)[股神](https://t.me/CF_NAT/38840)、ChatGPT

0 commit comments

Comments
 (0)