Dockerfile for leptos
This commit is contained in:
parent
d4bba3843d
commit
9a6fa4d497
2 changed files with 49 additions and 38 deletions
|
|
@ -1,11 +1,10 @@
|
||||||
/public/style.css
|
target/
|
||||||
|
wallpapers.json
|
||||||
|
|
||||||
/target/
|
.idea/
|
||||||
|
.vscode/
|
||||||
/.idea/
|
|
||||||
/.vscode/
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.gitea/
|
.gitea/
|
||||||
/readme.md
|
readme.md
|
||||||
/Dockerfile
|
Dockerfile
|
||||||
/.dockerignore
|
.dockerignore
|
||||||
|
|
|
||||||
72
Dockerfile
72
Dockerfile
|
|
@ -1,39 +1,51 @@
|
||||||
ARG RUST_VERSION=1.74.0
|
ARG RUST_VERSION=1.77
|
||||||
|
FROM rust:${RUST_VERSION}-bookworm as builder
|
||||||
|
|
||||||
FROM rust:${RUST_VERSION}-slim-bookworm 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
|
||||||
|
|
||||||
# tailwind
|
# Install cargo-leptos
|
||||||
WORKDIR /usr/bin/
|
RUN cargo binstall cargo-leptos -y
|
||||||
ADD https://github.com/tailwindlabs/tailwindcss/releases/download/v3.3.5/tailwindcss-linux-x64 tailwindcss
|
|
||||||
RUN chmod +x /usr/bin/tailwindcss
|
|
||||||
|
|
||||||
# openssl + CA certs
|
# Add the WASM target
|
||||||
RUN apt-get update; \
|
RUN rustup target add wasm32-unknown-unknown
|
||||||
apt-get install -y --no-install-recommends ca-certificates pkg-config libssl-dev
|
|
||||||
|
|
||||||
WORKDIR /usr/src/plcom
|
# Make an /app dir, which everything will eventually live in
|
||||||
COPY css/ css/
|
RUN mkdir -p /app
|
||||||
COPY public/ public/
|
WORKDIR /app
|
||||||
COPY templates/ templates/
|
COPY . .
|
||||||
COPY src/ src/
|
|
||||||
COPY build.rs .
|
|
||||||
COPY Cargo.lock .
|
|
||||||
COPY Cargo.toml .
|
|
||||||
COPY tailwind.config.cjs .
|
|
||||||
|
|
||||||
# generate wallpapers
|
# Generate wallpapers metadata
|
||||||
RUN cargo build --bin gen-wallpapers --release
|
RUN cargo run -p gen-wallpapers --example cli -- ./public/wallpapers > crates/plcom/wallpapers.json
|
||||||
RUN cargo run --bin gen-wallpapers --release
|
|
||||||
|
|
||||||
# build project
|
# Build the app
|
||||||
RUN cargo build --bin plcom --release
|
RUN cargo leptos build --release -vv
|
||||||
|
|
||||||
FROM debian:12-slim
|
FROM debian:bookworm-slim as runtime
|
||||||
WORKDIR /usr/share/plcom
|
WORKDIR /app
|
||||||
COPY --from=builder /usr/src/plcom/public /usr/share/plcom/public
|
RUN apt-get update -y \
|
||||||
COPY --from=builder /usr/src/plcom/target/release/plcom /usr/share/plcom
|
&& apt-get install -y --no-install-recommends openssl ca-certificates \
|
||||||
|
&& apt-get autoremove -y \
|
||||||
|
&& apt-get clean -y \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
ENV ROCKET_CLI_COLORS=0
|
# Copy the server binary to the /app directory
|
||||||
ENV ROCKET_ADDRESS=0.0.0.0
|
COPY --from=builder /app/target/release/plcom /app/
|
||||||
|
|
||||||
|
# /target/site contains our JS/WASM/CSS, etc.
|
||||||
|
COPY --from=builder /app/target/site /app/site
|
||||||
|
|
||||||
|
# Copy Cargo.toml if it’s needed at runtime
|
||||||
|
COPY --from=builder /app/Cargo.toml /app/
|
||||||
|
|
||||||
|
# Set any required env variables and
|
||||||
|
ENV RUST_LOG="info"
|
||||||
|
ENV LEPTOS_SITE_ADDR="0.0.0.0:8000"
|
||||||
|
ENV LEPTOS_SITE_ROOT="site"
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
ENTRYPOINT ["/usr/share/plcom/plcom"]
|
|
||||||
|
# Run the server
|
||||||
|
CMD ["/app/plcom"]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue