diff --git a/package.json b/package.json index 2c6ea4b..25647d7 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "@ianvs/prettier-plugin-sort-imports": "4.1.0", "@next/eslint-plugin-next": "13.5.4", "@types/node": "18.11.10", + "@types/react": "^18.2.31", "@typescript-eslint/eslint-plugin": "6.7.4", "@typescript-eslint/parser": "6.7.4", "autoprefixer": "^10.4.16", diff --git a/pages/docs/_meta.json b/pages/docs/_meta.json index e7e884e..65506bf 100644 --- a/pages/docs/_meta.json +++ b/pages/docs/_meta.json @@ -1,7 +1,5 @@ { - "-- Getting Started --": { - "type": "separator", - "title": "Getting Started" - }, - "index": "Introduction" + "index": "Introduction", + "getting-started": "Getting Started", + "user-guide": "User Guide" } diff --git a/pages/docs/getting-started/_meta.json b/pages/docs/getting-started/_meta.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/pages/docs/getting-started/_meta.json @@ -0,0 +1 @@ +{} diff --git a/pages/docs/user-guide/_meta.json b/pages/docs/user-guide/_meta.json new file mode 100644 index 0000000..01a8529 --- /dev/null +++ b/pages/docs/user-guide/_meta.json @@ -0,0 +1,4 @@ +{ + "compile-kernel": "Compiling the Kernel", + "build-initramfs": "Build initramfs" +} diff --git a/pages/docs/user-guide/build-initramfs.mdx b/pages/docs/user-guide/build-initramfs.mdx new file mode 100644 index 0000000..50f74bb --- /dev/null +++ b/pages/docs/user-guide/build-initramfs.mdx @@ -0,0 +1,115 @@ +import Image from 'next/image'; +import Link from 'next/link'; +import InitramfsComponentsImage from '../../../public/images/schemas/initramfs-components.png'; + +# Building initramfs + +Requirements: + +- [Rust toolchain](https://www.rust-lang.org/fr/learn/get-started) + +## Introduction + +Lambdo uses custom initramfs builded from Docker images. You can build it by +yourself or use prebuilt one. + +## Lambdo initramfs structure + +Lambdo initramfs contains at least 3 components: + +- **init** - init process which starts all other processes. +- **agent** - agent process which is responsible for communication with Lambdo + API. +- **config.yaml** - configuration file which contains all necessary + configuration for Lambdo agent (see + [Configuration documentation](/docs/reference/configuration)). + +
+ Initramfs components +
+ +## Preparation + +Create an empty directory for initramfs: + +```bash copy +mkdir initramfs +``` + +Clone `lambdo` repository: + +```bash copy +git clone https://github.com/faast-rt/lambdo.git +``` + +## Build Lambdo agent + +Build Lambdo agent and move it to initramfs directory: + +```bash copy +cd lambdo/agent +cargo build --release +cd ../.. +mv lambdo/target/release/agent initramfs +``` + +## Write init script + +You can write your own script or use example one (must be named `init`): + +```bash copy filename="initramfs/init" +#! /bin/sh +mount -t devtmpfs dev /dev +mount -t proc proc /proc +mount -t sysfs sysfs /sys +ip link set up dev lo + +exec /agent --config /config.yaml + +exit +poweroff -f +``` + +> **Note 1:** Your init script must be executable. + +> **Note 2:** Your init script must start agent process. + +## Write configuration file + +You can write your own configuration file or use example one (must be named +`config.yaml`): + +```yaml copy filename="initramfs/config.yaml" +apiVersion: lambdo.io/v1alpha1 +kind: AgentConfig +serial: + path: /dev/pts/6 + baudRate: 9600 +``` + +## Build initramfs by yourself + +Build initramfs tool and move it to initramfs directory: + +```bash copy +cd lambdo/initramfs +cargo build --release +cd ../.. +mv lambdo/target/release/initramfs initramfs +``` + +Run initramfs tool (replace `node:20-alpine` with the image of the language you +want): + +```bash copy +cd initramfs +./initramfs --image node:20-alpine +``` + +**The image built here is stored at +`initramfs/initramfs-library-node-20-alpine.img`.** diff --git a/pages/docs/user-guide/compile-kernel.mdx b/pages/docs/user-guide/compile-kernel.mdx new file mode 100644 index 0000000..6bf9b69 --- /dev/null +++ b/pages/docs/user-guide/compile-kernel.mdx @@ -0,0 +1,49 @@ +# Compiling Linux kernel + +Lambdo uses a Linux kernel compiled from source. This is a guide to compile the +kernel. + +## Install dependencies + +#### Debian/Ubuntu + +```bash copy filename="bash" +sudo apt update +sudo apt install git build-essential bc flex bison +``` + +#### Fedora/RHEL/CentOS + +```bash copy filename="bash" +sudo dnf install git gcc make xz bc flex bison diffutils +``` + +#### Arch Linux + +```bash copy filename="bash" +sudo pacman -Syu +sudo pacman -S git gcc make xz bc flex bison diffutils +``` + +## Build the kernel + +Clone the Linux kernel official repository: + +```bash copy filename="bash" +git clone https://github.com/torvalds/linux.git +``` + +Generate the default configuration: + +```bash copy filename="bash" +cd linux +sudo make tinyconfig +``` + +Compile the kernel: + +```bash copy filename="bash" +KCFLAGS="-Wa,-mx86-used-note=no" sudo make bzImage -j `nproc` +``` + +**The image is located at `arch/x86/boot/compressed/vmlinux.bin`** diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2146fe5..466b155 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -34,6 +34,9 @@ devDependencies: '@types/node': specifier: 18.11.10 version: 18.11.10 + '@types/react': + specifier: ^18.2.31 + version: 18.2.31 '@typescript-eslint/eslint-plugin': specifier: 6.7.4 version: 6.7.4(@typescript-eslint/parser@6.7.4)(eslint@8.51.0)(typescript@4.9.3) @@ -426,7 +429,7 @@ packages: react: '>=16' dependencies: '@types/mdx': 2.0.3 - '@types/react': 18.0.25 + '@types/react': 18.2.31 react: 18.2.0 dev: false @@ -772,19 +775,16 @@ packages: /@types/prop-types@15.7.5: resolution: {integrity: sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==} - dev: false - /@types/react@18.0.25: - resolution: {integrity: sha512-xD6c0KDT4m7n9uD4ZHi02lzskaiqcBxf4zi+tXZY98a04wvc0hi/TcCPC2FOESZi51Nd7tlUeOJY8RofL799/g==} + /@types/react@18.2.31: + resolution: {integrity: sha512-c2UnPv548q+5DFh03y8lEDeMfDwBn9G3dRwfkrxQMo/dOtRHUUO57k6pHvBIfH/VF4Nh+98mZ5aaSe+2echD5g==} dependencies: '@types/prop-types': 15.7.5 '@types/scheduler': 0.16.2 csstype: 3.1.1 - dev: false /@types/scheduler@0.16.2: resolution: {integrity: sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==} - dev: false /@types/semver@7.5.4: resolution: {integrity: sha512-MMzuxN3GdFwskAnb6fz0orFvhfqi752yjaXylr0Rp4oDg5H0Zn1IuyRhDVvYOwAXoJirx2xuS16I3WjxnAIHiQ==} @@ -1422,7 +1422,6 @@ packages: /csstype@3.1.1: resolution: {integrity: sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw==} - dev: false /debug@3.2.7: resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} diff --git a/public/images/schemas/initramfs-components.png b/public/images/schemas/initramfs-components.png new file mode 100644 index 0000000..11dc500 Binary files /dev/null and b/public/images/schemas/initramfs-components.png differ