-
-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Document recommended deployment environment #332
Comments
Personally, I'd lean towards crate2nix and
However, it does have some disadvantages...
|
cargo-wharf is good at caching too. |
Oh, that's interesting. The caching seems stronger than for the plain |
For what its work I've been using ekidd/rust-musl-builder as my builder. Here is an example: FROM ekidd/rust-musl-builder:stable as builder
ENV APP=my-app
RUN mkdir .cargo src
COPY Cargo.toml Cargo.toml
COPY Cargo.lock Cargo.lock
RUN echo "fn main() {println!(\"if you see this, the build broke\")}" > src/lib.rs && \
cargo vendor > .cargo/config && \
cargo build --release && \
rm -rf src
COPY src src
RUN rm -rf target/release/**/libsrc*
RUN cargo build --release
FROM alpine:latest
ARG APP_FOLDER=/usr/src/app
ENV APP_USER=appuser
RUN addgroup -S $APP_USER \
&& adduser -S -g $APP_USER $APP_USER
RUN apk update \
&& apk add --no-cache ca-certificates open-ssl \
&& rm -rf /var/cache/apk/*
COPY --from=builder /home/rust/src/target/x86_64-unknown-linux-musl/release/${APP} ${APP_FOLDER}/${APP}
ENV PATH="${APP_FOLDER}:${PATH}"
CMD ["${APP}"] Replaced the hacky method with cargo chef FROM ekidd/rust-musl-builder:stable as planner
RUN cargo install cargo-chef
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM ekidd/rust-musl-builder:stable as cacher
RUN cargo install cargo-chef
COPY --from=planner /home/rust/src/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
FROM ekidd/rust-musl-builder:stable as builder
COPY . .
COPY --from=cacher /home/rust/src/target target
COPY --from=cacher /home/rust/.cargo /home/rust/.cargo
RUN cargo build --release
FROM alpine:latest
ENV APP=my-app
ARG APP_FOLDER=/usr/src/app
ENV APP_USER=appuser
RUN addgroup -S $APP_USER \
&& adduser -S -g $APP_USER $APP_USER
RUN apk update \
&& apk add --no-cache ca-certificates \
&& rm -rf /var/cache/apk/*
COPY --from=builder /home/rust/src/target/x86_64-unknown-linux-musl/release/${APP} ${APP_FOLDER}/${APP}
ENV PATH="${APP_FOLDER}:${PATH}"
CMD ${APP} |
#331 highlights that this can be pretty confusing at the moment...
Arguably this isn't really specific to
kube-rs
, but at the same time it's probably something that will be relevant for 99% ofkube-rs
users.The text was updated successfully, but these errors were encountered: