portfolio_leptos/Dockerfile

46 lines
1.4 KiB
Text
Raw Permalink Normal View History

2023-10-12 20:32:43 +02:00
# Get started with a build env with Rust nightly
FROM docker.io/rustlang/rust:nightly-bullseye as builder
# If youre using stable, use this instead
# FROM docker.io/rust:1.70-bullseye as builder
# Install cargo-binstall, which makes it easier to install other
# cargo extensions like cargo-leptos
RUN wget https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz
RUN tar -xvf cargo-binstall-x86_64-unknown-linux-musl.tgz
RUN cp cargo-binstall /usr/local/cargo/bin
# Install cargo-leptos
RUN cargo binstall cargo-leptos -y
# Add the WASM target
RUN rustup target add wasm32-unknown-unknown
# Make an /app dir, which everything will eventually live in
RUN mkdir -p /app
WORKDIR /app
COPY . .
# Build the app
2023-11-21 22:07:45 +01:00
ENV CARGO_BUILD_JOBS=2
2023-11-21 21:10:39 +01:00
RUN cargo leptos build --release -vv
2023-10-12 20:32:43 +02:00
FROM rustlang/rust:nightly-bullseye as runner
# Copy the server binary to the /app directory
COPY --from=builder /app/target/release/portfolio /app/
# /target/site contains our JS/WASM/CSS, etc.
COPY --from=builder /app/target/site /app/site
# Copy Cargo.toml if its needed at runtime
COPY --from=builder /app/Cargo.toml /app/
2023-12-09 22:37:14 +01:00
# Copy all data files
COPY --from=builder /app/data_src /app/data_src
2023-10-12 20:32:43 +02:00
WORKDIR /app
# Set any required env variables and
ENV RUST_LOG="warn"
2023-10-12 20:32:43 +02:00
ENV APP_ENVIRONMENT="production"
ENV LEPTOS_SITE_ADDR="0.0.0.0:8080"
ENV LEPTOS_SITE_ROOT="site"
EXPOSE 8080
# Run the server
CMD ["/app/portfolio"]