jimmy/events (#6)
Co-authored-by: Jimmy Vargo <james@ayo.tokyo> Reviewed-on: ayo/website#6
This commit is contained in:
parent
83a0903155
commit
e3ddda951f
76 changed files with 564 additions and 1 deletions
|
|
@ -0,0 +1,78 @@
|
|||
# Self-Hosted Web Infrastructure
|
||||
*Posted on September, 12 2023*
|
||||
|
||||
## Preambule
|
||||
|
||||
This month I had to setup a new server to host this very website as well as additional subdomains for self-hosted Git and Doc/Calendar sharing application. All of this doesn't require any big hardware and can be handled by a small IoT in my office.
|
||||
|
||||
Deploying a server, even a small and simple one, has some caveats that need to be taken into consideration. I will share the setup I just did for the last server I am using to host my application in-house.
|
||||
|
||||
## Hardware consideration
|
||||
|
||||
The first name that is probably coming to everyone is Raspberry-pi. It's capable enough, this website was hosted on a ~8 years old raspberry-pi 2 until now. I have also worked for different project with raspberry-pis (magic-mirror, robot-arm control with multi-camera setup, etc) and it was always very frustrating.
|
||||
|
||||
Here's a quick overview of the problems I know:
|
||||
|
||||
* GPU capabilities were not great because the vendor Broadcom wasn't helpful with the FOSS (Free Open Sourced Software) community and the driver was lacking. This means that outputing realtime images/video and overlay would be very slow unless you switched to the experimental driver. The experimental driver has issues such as stability, and I even got noisy output (bearable, only few pixels here and there but weird nonetheless).
|
||||
* No real ethernet but ethernet over USB (was fixed from version 3 or 4), coupling with a single not-so-powerful USB controller, this would lead to USB congestion. For instance you couldn't use 2 webcams in 720p resolution at 30 fps (not even sure about 480p, I had to tune down the resolution and FPS a lot). During USB congestion any SSH session would get stuck working with such a device.
|
||||
* SD card reader was extremely slow (version 1 and 2, probably 3 too)
|
||||
* With time the value proposition gets worse for the price : the raspberry-pi started as a cheap computer experience for educational purposes and prototyping. But now the price is quadruple for performance that is not even above average compared to other devices.
|
||||
* Version 4 opted for a micro-HDMI instead of full-sized
|
||||
|
||||
There are many alternatives I looked at, among them one caught my attention : Odroid. This device was widely known for a long time and the company, based in South-Korea, is now named hardkernel. The proximity of the company is very nice and the catalog they offer is very interesting. Here are a few points that made me, over time, look mostly at them for my IoT needs:
|
||||
|
||||
* Very focused on making hardware and not selling other things
|
||||
* Great value proposition for the price : especially for the accessories (power supply, cases, etc)
|
||||
* Updating hardware frequently : you are not stuck buying a 5 year old CPU
|
||||
* Hardware is documented : schematics and even benchmarks (performance and power consumption)!
|
||||
* Amazing support : I once had a problem with a single component, reaching to them by email I had a response immediately and they shipped me a replacement for free in the next order I made (I asked for that specifically as I was buying a new device to make my NAS).
|
||||
|
||||
Long story short : I eventually have ended up using the Odroid-N2+ device multiple times and it is mostly flawless (using panfrost driver for the GPU is tricky). You can check [all the specifications from hardkernel's website](https://www.hardkernel.com/shop/odroid-n2-with-4gbyte-ram-2).
|
||||
|
||||
<div class="image-row">
|
||||
|
||||
### Odroid N2+
|
||||
|
||||

|
||||
|
||||
</div>
|
||||
|
||||
|
||||
## OS/Distribution
|
||||
|
||||
### Distribution Choice
|
||||
|
||||
Finding a good Linux distribution can be troublesome too. For me the choice is not too hard to make : I come from a Debian background and most of the corporate-minded distributions such as CentOS(discontinued now)/RHEL have no appeal to me. I can fix my issues and contribute back if needed, I don't need support.
|
||||
|
||||
[Debian](https://wiki.debian.org) is amazing at its job : being stable. The people maintaining it are probably the most professional and rigorous I've seen. There is one drawback of the distribution : everything is ~3 years old. Because of my bias with deep learning engineering needing more recent libraries, and issues that I had in the past with too-old databases (namely MySQL) to get very important features, I am choosing another distribution. Also note that official Debian does not offer a lot of possibilities for [Arm ports](https://wiki.debian.org/Arm64Port).
|
||||
|
||||
For IoTs [Armbian](https://www.armbian.com/) is amazing and definitely a strong choice. I am using this in some of my devices, it has very interesting defaults that I will get inspiration from (like on-memory logs).
|
||||
|
||||
Being familiar with ArchLinux, [ArchLinuxArm](https://archlinuxarm.org/) is a perfect fit for me. I like the deliberate choice to leave configurations as software's default. It takes some work off the maintainer and onto the user. A lot of softwares improved their defaults in the last years anyway and it gives more knowledge/control to the user.
|
||||
|
||||
**Note :** Another noticeable distribution is [Manjaro Arm](https://manjaro.org/download/#ARM), on x86-64 platform there are differences between ArchLinux and Manjaro that spark a lot of debate. But on Arm platforms ArchLinuxArm is a totally different project and there Manjaro can bring a lot of value : packages can be better maintained (noticeable if you want the latest GPU driver).
|
||||
|
||||
### Installation
|
||||
|
||||
Compared to PC installation, installing ArchLinux for Arm platforms is way more straightforward. The boot sequence of Arm devices is very different and I have never seen UEFI on Arm. Also Arm devices boot thanks to device tree (declared is .dts files in the kernel code directly and compiled to .dtb files), those describe all the hardware and the initialization values to make the device works. This means that the Linux project has hundreds, if not thousands, of those files to be able to run on any device (the dts can be targeting a family of devices shared thus far).
|
||||
|
||||
Installing Linux on an IoT usually means copying a prepared image on an SD card or other storage. Sometimes with the DTB files given in a separate boot partition for linux to boot with. Also additional initiazition values can be set in the boot partition in a `boot.ini` files. The boot sequence usually starts not from Linux but from a boot loader : on PC Grub is a common one, on IoT you may encounter `u-boot` and more rarely `petitboot`. Those are usually already prepared so nothing needs to be done on that part.
|
||||
|
||||
For ArchLinuxArm preparing the partition on the storage is the biggest part of the installation but only requires ~10 commands and is nicely documented. For the Odroid-N2 the procedure is described [here](https://archlinuxarm.org/platforms/armv8/amlogic/odroid-n2).
|
||||
|
||||
Additional commands you probably want to do at first, as root, would be:
|
||||
|
||||
* **Edit pacman (the package manager) configuration** : `vim /etc/pacman.conf` (here using `vim`, but `nano` would also work fine). Uncommenting the `Color`, `VerbosePkgLists` and `ParallelDownloads` is a must have.
|
||||
* **Update all packages** : `pacman -Syu`
|
||||
* **Installing sudo** : `pacman -S sudo`
|
||||
* **Create sudo group and add your user to it** : `groupadd sudo` and `usermod -aG sudo myuser`.
|
||||
* **Allow sudo group to run any command** : `EDITOR=vim visudo /etc/sudoers` (again `nano` would work instead of `vim`). Make sure the line `%sudo ALL=(ALL:ALL) ALL` is uncommented.
|
||||
* **Adding your user** : `useradd -m myuser`. The `-m` option is to create a home folder (`/home/myuser`)
|
||||
* **Setting your user password** : `passwd myuser`.
|
||||
|
||||
|
||||
## Conclusion
|
||||
|
||||
I hope this introduction to the hardware and software used for self hosting was interesting and maybe gave you some thoughts about trying it yourself. There are many topics from here that I will present : security, server software installation and configuration, DNS, certificates, etc. Stay tuned for the next post.
|
||||
|
||||
Corentin Risselin.
|
||||
Loading…
Add table
Add a link
Reference in a new issue