FROM rust:latest as build
# FROM rust:1.50 as builder
# Use prebuilt builder image
# FROM rust:1.50-prebuilt as builder
# RUN rustup target add x86_64-unknown-linux-musl
# RUN apt-get update && apt-get install -y musl-tools
# 使用 sed 修改 Rust 源为 163 的镜像源
# RUN sed -i 's#https://mirrors.ustc.edu.cn/rust-static#https://mirrors.163.com/crates-io#g' /usr/local/cargo/config
# 设置 Rust 默认工具链版本
# ENV RUST_VERSION=nightly
# 设置工作目录
WORKDIR /app
# 复制整个工作区根目录(含./Cargo.toml和所有members)
COPY . /app
# 安装
# RUN cargo install
# RUN cargo install --path . --color always
RUN rustc --version
RUN cargo build -p fache --release
# RUN mv ../../.cargo/config.toml ../../.cargo/config.tomls
# RUN cargo build --target=x86_64-unknown-linux-musl --release
# 登录 cargo 后台
# RUN cargo login cioXCgy1n1NuJWWD1vlIvWQtgAHOhAntSpU
RUN echo "ciodlVrw4qrSwRc07PYRBydruVHbc3FqsGA" | cargo login --registry crates-io
# 推送到后台
# RUN cargo publish
# RUN cargo publish --allow-dirty
RUN cargo publish -p fache --allow-dirty --registry crates-io
# RUN mv ../../.cargo/config.tomls ../../.cargo/config.toml
# 切换容器运行的用户
# USER 1000
RUN ls -a
# ENTRYPOINT ["/$APP"]
# 启动应用程序
# CMD ["cargo", "run"]