代码拉取完成,页面将自动刷新
FROM ekidd/rust-musl-builder:1.48.0 as cargo-build
USER root
RUN rustup default stable
RUN rustup target add x86_64-unknown-linux-musl
RUN sed -i "s@http://\(deb\|security\).debian.org@https://mirrors.aliyun.com@g" /etc/apt/sources.list
RUN apt-get clean
RUN apt-get update
RUN apt-get install -y protobuf-compiler
RUN apt-get install -y musl musl-dev musl-tools
RUN mkdir -p /root/.cargo
COPY docker/.cargo/config /root/.cargo/
RUN export CARGO_HTTP_DEBUG=true
RUN export CARGO_LOG=cargo::ops::registry=debug
RUN mkdir -p /home/axum-grpc-demo
RUN mkdir -p /home/axum-grpc-demo/.cargo
COPY docker/.cargo/config /home/axum-grpc-demo/.cargo/
WORKDIR /home/axum-grpc-demo
COPY Cargo.toml Cargo.toml
RUN mkdir src/
RUN echo "fn main() {println!(\"if you see this, the build broke\")}" > src/main.rs
RUN RUSTFLAGS=-Clinker=musl-gcc cargo build -v --release --target=x86_64-unknown-linux-musl
RUN rm -f target/x86_64-unknown-linux-musl/release/deps/axum-grpc-demo*
COPY proto /home/axum-grpc-demo/proto
COPY src /home/axum-grpc-demo/src
COPY build.rs /home/axum-grpc-demo/
RUN RUSTFLAGS=-Clinker=musl-gcc cargo build -v --release --target=x86_64-unknown-linux-musl
FROM alpine:latest
USER root
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN mkdir -p /home/myapp/bin/
WORKDIR /home/myapp/bin/
COPY --from=cargo-build /home/axum-grpc-demo/target/x86_64-unknown-linux-musl/release/axum-grpc-demo .
RUN addgroup -g 1000 myapp
RUN adduser -D -s /bin/sh -u 1000 -G myapp myapp
RUN chown myapp:myapp axum-grpc-demo
RUN chgrp -R myapp /tmp
RUN chmod -R g+w /tmp
#时区设置上海
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone
USER myapp
EXPOSE 8080
ENTRYPOINT ./axum-grpc-demo
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。