Skip to content

Commit 23e7668

Browse files
committed
build(docker): 优化 Docker 构建过程
1 parent 128af17 commit 23e7668

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.github
2+
/target/

Dockerfile

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,29 @@ RUN ln -s $HOME/.cargo/bin/rustup /usr/local/bin/rustup
2323
RUN ln -s $HOME/.cargo/bin/cargo /usr/local/bin/cargo
2424

2525
# 导入cargo配置
26-
COPY proxy_config $HOME/.cargo/config
26+
COPY cargo.config $HOME/.cargo/config.toml
2727

2828
WORKDIR /satex
2929

3030
# 复制文件
31-
COPY src ./src
32-
COPY crates ./crates
33-
COPY Cargo.toml .
34-
COPY Cargo.lock .
31+
COPY . .
3532

3633
# 编译
3734
RUN cargo build --release
3835

3936
FROM alpine:latest
4037

41-
WORKDIR /satex
38+
WORKDIR /app
4239

4340
# 复制构建文件
44-
COPY --from=build-env /satex/target/release/satex ./bin/
41+
COPY --from=build-env /satex/target/release/satex .
4542

4643
# 复制配置文件
47-
COPY examples/docker/satex.yaml ./conf/
48-
COPY examples/docker/static.yaml ./conf/
49-
COPY examples/resources ./static/
44+
COPY ./satex.yaml .
45+
5046

5147
# 暴露端口
5248
EXPOSE 80
5349

5450
# 启动
55-
ENTRYPOINT ["/satex/bin/satex", "-c", "/satex/conf/satex.yaml"]
51+
ENTRYPOINT ["/app/satex", "-c", "/app/satex.yaml"]

cargo.config

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[source.crates-io]
2+
replace-with = 'rsproxy-sparse'
3+
[source.rsproxy]
4+
registry = "https://rsproxy.cn/crates.io-index"
5+
[source.rsproxy-sparse]
6+
registry = "sparse+https://rsproxy.cn/index/"
7+
[registries.rsproxy]
8+
index = "https://rsproxy.cn/crates.io-index"
9+
[net]
10+
git-fetch-with-cli = true

0 commit comments

Comments
 (0)