feat(web): add Dockerfile

This commit is contained in:
Kristofers Solo 2025-11-26 05:49:24 +02:00
parent bb7ef246f8
commit ce3a09088f
Signed by: kristoferssolo
GPG Key ID: 8687F2D3EEE6F0ED
5 changed files with 101 additions and 20 deletions

27
.dockerignore Normal file
View File

@ -0,0 +1,27 @@
# Rust
target/
Cargo.lock
*.rlib
*.rmeta
# Node/npm
node_modules/
package-lock.json
npm-debug.log
# IDE
.vscode/
.idea/
*.swp
*.swo
*~
.DS_Store
# Git
.git/
.gitignore
# General
*.log
.env
.env.local

3
.env Normal file
View File

@ -0,0 +1,3 @@
RUST_LOG=info
LEPTOS_SITE_ADDR=0.0.0.0:8080
LEPTOS_SITE_ROOT=site

View File

@ -8,34 +8,28 @@ authors = ["Kristofers Solo <dev@kristofers.xyz>"]
edition = "2024"
[workspace.dependencies]
aes = { path = "aes" }
cipher-core = { path = "cipher-core" }
cipher-factory = { path = "cipher-factory" }
claims = "0.8"
clap = { version = "4.5", features = ["derive"] }
color-eyre = "0.6"
des = { path = "des" }
rand = "0.9"
rstest = "0.26"
strum = "0.27"
thiserror = "2"
[workspace.dependencies.aes]
path = "aes"
[workspace.dependencies.cipher-core]
path = "cipher-core"
[workspace.dependencies.cipher-factory]
path = "cipher-factory"
[workspace.dependencies.clap]
version = "4.5"
features = ["derive"]
[workspace.dependencies.des]
path = "des"
[workspace.dependencies.zeroize]
version = "1.8"
features = ["derive"]
zeroize = { version = "1.8", features = ["derive"] }
[workspace.lints.clippy]
nursery = "warn"
pedantic = "warn"
unwarp_used = "warn"
# Defines a size-optimized profile for the WASM bundle in release mode
[profile.wasm-release]
inherits = "release"
opt-level = 'z'
lto = true
codegen-units = 1
panic = "abort"

48
Dockerfile Normal file
View File

@ -0,0 +1,48 @@
FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
WORKDIR /app
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM rustlang/rust:nightly-bookworm AS cacher
RUN curl -LO 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
RUN cargo binstall cargo-leptos cargo-chef -y
RUN apt-get update -y && apt-get install -y --no-install-recommends clang
RUN rustup target add wasm32-unknown-unknown
WORKDIR /app
COPY --from=chef /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
FROM rustlang/rust:nightly-bookworm AS builder
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
RUN cargo binstall cargo-leptos -y
RUN apt-get update -y && apt-get install -y --no-install-recommends clang
RUN rustup target add wasm32-unknown-unknown
WORKDIR /app
COPY --from=cacher /app/target target
COPY . .
RUN cargo leptos build --release -vv
FROM debian:bookworm-slim AS runtime
WORKDIR /app
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends openssl ca-certificates \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/web /app/
COPY --from=builder /app/target/site /app/site
COPY --from=builder /app/Cargo.toml /app/
EXPOSE 8080
CMD ["/app/web"]

9
docker-compose.yml Normal file
View File

@ -0,0 +1,9 @@
services:
web:
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:8080"
env_file: .env
restart: unless-stopped