From 747df0e7e5e422d2c193a95c935ed169c8873239 Mon Sep 17 00:00:00 2001 From: Lucas Vas Date: Sat, 24 May 2025 15:53:03 -0400 Subject: [PATCH] feat: dockerfile improvements --- .dockerignore | 3 +++ Dockerfile | 19 +++++++++++-------- docker-compose.yml | 9 +++++++++ 3 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 .dockerignore create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..1d0c0e2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +node_modules +target +.git diff --git a/Dockerfile b/Dockerfile index b9bd9bc..c24d621 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,28 @@ FROM rust:1.86 AS builder # Install node for tailwind capability -RUN apt-get update -y && apt-get install -y --no-install-recommends clang libc6 nodejs npm -RUN node -v -RUN npm -v - +RUN apt-get update -y && apt-get install -y --no-install-recommends clang libc6 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 curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash RUN cargo binstall cargo-leptos -y - RUN rustup target add wasm32-unknown-unknown +# Set up working directory RUN mkdir -p /app WORKDIR /app COPY . . -RUN npm install tailwindcss @tailwindcss/cli - -RUN cargo leptos build --release -vv +# Setup fnm and build with leptos +RUN cargo binstall fnm -y \ + && fnm --version \ + && eval "$(fnm env)" \ + && fnm install 20 \ + && fnm use 20 \ + && node -v \ + && npm install tailwindcss @tailwindcss/cli \ + && cargo leptos build --release -vv # Start second phase of build - install ca-certs and copy all build outputs from previous step into a # Debian image in the /app directory. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..02e8ee8 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ + +services: + leptos-watch: + image: rust:1.86 + ports: + - '3000:3000' + volumes: + - .:/app + command: cargo leptos watch