This commit is contained in:
parent
ac7cb0ddee
commit
4422a9d2c7
1 changed files with 21 additions and 22 deletions
43
Dockerfile
43
Dockerfile
|
|
@ -1,33 +1,32 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM rust:alpine as builder
|
||||
|
||||
RUN apk add --no-cache musl-dev openssl-dev openssl-libs-static protobuf-dev lld perl make
|
||||
|
||||
FROM rust:alpine AS chef
|
||||
RUN apk add --no-cache musl-dev lld g++ make perl openssl-dev openssl-libs-static protobuf-dev
|
||||
RUN cargo install cargo-chef
|
||||
WORKDIR /app
|
||||
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
COPY mii ./mii
|
||||
RUN mkdir src && echo "fn main() {println!(\"dummy\");}" > src/main.rs
|
||||
RUN OPENSSL_LIB_DIR=/usr/lib OPENSSL_INCLUDE_DIR=/usr/include/openssl OPENSSL_STATIC=1 RUSTFLAGS="-C target-feature=+aes,+sse -C relocation-model=static -C linker=ld.lld" cargo build --target x86_64-unknown-linux-musl --profile prod
|
||||
|
||||
FROM chef AS planner
|
||||
COPY . .
|
||||
RUN cargo chef prepare --recipe-path recipe.json
|
||||
|
||||
RUN touch src/main.rs
|
||||
FROM chef AS builder
|
||||
COPY --from=planner /app/recipe.json recipe.json
|
||||
|
||||
ENV SQLX_OFFLINE=true
|
||||
RUN RUSTFLAGS="-C target-feature=+aes,+sse -C relocation-model=static -C linker=ld.lld" cargo build --profile prod --target x86_64-unknown-linux-musl
|
||||
ENV RUSTFLAGS="-C target-feature=+aes,+sse -C relocation-model=static -C linker=ld.lld"
|
||||
|
||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,target=/app/target \
|
||||
cargo chef cook --profile prod --recipe-path recipe.json --target x86_64-unknown-linux-musl
|
||||
|
||||
COPY . .
|
||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,target=/app/target \
|
||||
cargo build --profile prod --target x86_64-unknown-linux-musl && \
|
||||
mkdir -p /app/dist && \
|
||||
cp /app/target/x86_64-unknown-linux-musl/prod/account /app/dist/
|
||||
|
||||
FROM scratch AS final
|
||||
|
||||
WORKDIR /
|
||||
|
||||
# Copy the compiled binary from the builder stage
|
||||
COPY --from=builder /app/target/x86_64-unknown-linux-musl/prod/account /account
|
||||
COPY --from=builder /app/dist/account /account
|
||||
COPY --from=builder /app/res /res
|
||||
|
||||
# Set executable permissions
|
||||
# RUN chmod +x /account
|
||||
|
||||
# Command to run the application
|
||||
ENTRYPOINT ["/account"]
|
||||
ENTRYPOINT ["/account"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue