From de8aa2129cb13fe9cfb88856a2dca64972ae4ada Mon Sep 17 00:00:00 2001 From: Laurin Weger Date: Wed, 3 Jul 2024 15:20:26 +0200 Subject: [PATCH] chore: add docker images for building nextgraph-rs --- docker/Dockerfile.alpine | 36 ++++++++++++++++++++++++++++++ docker/Dockerfile.fedora | 46 +++++++++++++++++++++++++++++++++++++++ docker/Dockerfile.ubuntu | 47 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 docker/Dockerfile.alpine create mode 100644 docker/Dockerfile.fedora create mode 100644 docker/Dockerfile.ubuntu diff --git a/docker/Dockerfile.alpine b/docker/Dockerfile.alpine new file mode 100644 index 0000000..c77517c --- /dev/null +++ b/docker/Dockerfile.alpine @@ -0,0 +1,36 @@ +# Use rust's latest alpine image as base image. +FROM rust:alpine + +ENV LD_LIBRARY_PATH=/lib:$LD_LIBRARY_PATH + +RUN apk add git nodejs npm llvm-static llvm-dev clang-static clang-dev openssl openssl-dev perl gtk+3.0-dev webkit2gtk-dev librsvg-dev curl wget pkgconf eudev-dev build-base zlib-static bzip2-static build-base ncursers-static && \ + # Install Rust and Node.js tools + cargo install cargo-watch && \ + cargo install wasm-pack --git https://github.com/rustwasm/wasm-pack.git --rev c2b663f25abe50631a236d57a8c6d7fd806413b2 && \ + cargo install tauri-cli --version "2.0.0-alpha.11" --locked && \ + npm install -g pnpm + +# Clone the nextgraph-rs repository +RUN git clone https://git.nextgraph.org/NextGraph/nextgraph-rs.git && \ + cd /nextgraph-rs/ng-sdk-js && \ + wasm-pack build --target bundler && npm install --no-save pkg && + # Build ng-app web version + cd /nextgraph-rs/ng-app && pnpm install && pnpm webfilebuild + +# From here the build fails due to llvm / clang linking issues... +# +# WORKDIR /nextgraph-rs +## Build the nextgraph-rs project and its subprojects +# RUN cd /nextgraph-rs && git pull && cargo update -p ng-rocksdb && \ +# cargo build -r && \ +# cargo build -r -p ngd && \ +# cargo build -r -p ngcli + +# TODO: Build the platform-specific ng-app versions +# cd /nextgraph-rs/ng-app && cargo tauri build --target x86_64-unknown-linux-gnu +# ... + +# TODO: To remove the image size, remove ~/.cargo, ~/.rustup, and the build dependencies + +# To build the image, run: +# docker build -t nextgraph-rs:alpine -f docker/Dockerfile.alpine . diff --git a/docker/Dockerfile.fedora b/docker/Dockerfile.fedora new file mode 100644 index 0000000..c8b65d8 --- /dev/null +++ b/docker/Dockerfile.fedora @@ -0,0 +1,46 @@ +# Use fedora:40 as base image +FROM fedora:40 + +# Set the environment variable to ensure cargo is available in the PATH +ENV PATH="/root/.cargo/bin:${PATH}" +SHELL ["/bin/bash", "-c"] + +# Install the required packages and Rust + +RUN dnf install -y git clang-devel webkit2gtk4.1-devel openssl openssl-devel curl wget file libappindicator-gtk3-devel librsvg2-devel perl && \ + dnf group install -y "C Development Tools and Libraries" && \ + # Rust + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y && \ + # Node.js + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash && \ + export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && \ + nvm install 22 && \ + npm install -g pnpm && \ + # Clear Cache + rm -rf /var/cache/dnf && \ + # Install Rust and Node.js tools + cargo install cargo-watch && \ + cargo install wasm-pack --git https://github.com/rustwasm/wasm-pack.git --rev c2b663f25abe50631a236d57a8c6d7fd806413b2 && \ + cargo install tauri-cli --version "2.0.0-alpha.11" --locked && \ + # Clone the nextgraph-rs repository (TODO: It might be better to put this into a seperate RUN command to avoid rebuilding the image if the repository changes) + git clone https://git.nextgraph.org/NextGraph/nextgraph-rs.git && \ + # Build sdk and ng-app web version + cd /nextgraph-rs/ng-sdk-js && wasm-pack build --target bundler && npm install --no-save pkg && \ + cd /nextgraph-rs/ng-app && pnpm install && pnpm webfilebuild + +# Build the nextgraph-rs project +RUN export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && \ + cd /nextgraph-rs && git pull && cargo update -p ng-rocksdb && \ + cargo build -r && \ + cargo build -r -p ngd && \ + cargo build -r -p ngcli + + +# TODO: Build the platform-specific ng-app versions +# cd /nextgraph-rs/ng-app && cargo tauri build --target x86_64-unknown-linux-gnu +# ... + +# TODO: To remove the image size, remove ~/.cargo, ~/.rustup, and the build dependencies + +# To build the image, run: +# docker build -t nextgraph-rs:fedora -f docker/Dockerfile.fedora . diff --git a/docker/Dockerfile.ubuntu b/docker/Dockerfile.ubuntu new file mode 100644 index 0000000..60deb3e --- /dev/null +++ b/docker/Dockerfile.ubuntu @@ -0,0 +1,47 @@ +# Use ubuntu 22.04 as base image +FROM ubuntu:22.04 + +SHELL ["/bin/bash", "-c"] + +# Set the environment variable to ensure cargo is available in the PATH +ENV PATH="/root/.cargo/bin:${PATH}" + +# Install the required packages and Rust +RUN apt update && \ + apt upgrade -y && \ + apt install -y git llvm-dev libclang-dev clang libssl-dev perl libappindicator3-dev libwebkit2gtk-4.0-dev librsvg2-dev curl wget pkg-config libudev-dev build-essential && \ + rm -rf /var/cache/apt && \ + # Rust + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \ + # Node.js + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash && \ + export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && \ + nvm install 22 && \ + npm install -g pnpm && \ + # Install Rust and Node.js tools + cargo install cargo-watch && \ + cargo install wasm-pack --git https://github.com/rustwasm/wasm-pack.git --rev c2b663f25abe50631a236d57a8c6d7fd806413b2 && \ + cargo install tauri-cli --version "2.0.0-alpha.11" --locked && \ + npm install -g pnpm && \ + # Clone the nextgraph-rs repository (TODO: It might be better to put this into a seperate RUN command to avoid rebuilding the image if the repository changes) + git clone https://git.nextgraph.org/NextGraph/nextgraph-rs.git && \ + # Build sdk and ng-app web version + cd /nextgraph-rs/ng-sdk-js && wasm-pack build --target bundler && npm install --no-save pkg && \ + cd /nextgraph-rs/ng-app && \ + pnpm install && pnpm webfilebuild + +# Build the nextgraph-rs project and its subprojects +WORKDIR /nextgraph-rs +RUN cargo build -r && \ + cargo build -r -p ngd && \ + cargo build -r -p ngcli + + +# TODO: Build the platform-specific ng-app versions +# WORKDIR /nextgraph-rs/ng-app +# RUN cargo tauri build --target x86_64-unknown-linux-gnu + +# TODO: To remove the image size, remove ~/.cargo, ~/.rustup, and the build dependencies + +# To build the image, run: +# docker build -t nextgraph-rs:ubuntu -f docker/Dockerfile.ubuntu . -- 2.25.1