Tag: raspberrypi

A Developers Productivity Setup using a Raspberry Pi (4)

The Objective

I always wanted to have a workspace that could replace many a tool I use as a paid alternative or tools hosted in the cloud. Specially now, when most of the time I spend at home working, I have a need to manage my productivity. It uses docker for easy siloed management and it does not require any complicated system changes that break one app or the other. Additionally Dockerhub is a treasure of images that can be run very easily and can be leveraged.

The only drawback to using docker as an app deployment tool is that all the tools run in different ports and one has to remember the mappings. The mappings are easily visible in portainer and hence useful. Another useful technique is to locally install nginx and use it as reverse proxy.

NGINX Docs | NGINX Reverse Proxy

Tools Installed

  1. Portainer – Visual docker/container management web app. We will use portainer to deploy containers off dockerhub.
  2. BookStack – Notes taking and writing management tool.
  3. Wekan – A trello like Kanban Board/ Lists App.
  4. Bitwarden Server – To store all my passwords locally and not depend on passwords.google.com or Microsoft. Bitwarden is an open-source solution with a server, web app, browser plugin and iOS/Android apps.
  5. Pihole – To Manage my network and conserve my bandwidth. Primarily an Adblocker and I use this to manage intrusive ads on my parents phones and desktop. This I also use to manage access to devices.
  6. Prometheus/Grafana – Monitor the pi and network.
  7. FileBrowser – To manage additional storage. Simple file manager to manage an attached storage. Simply attach a drive to the pi. Attach it to /srv to mount it to the container.
  8. Draw.io – Diagramming Swiss knife.
  9. PlantUML Server – For UML Diagramming
  10. Hoppscotch – REST/Web Socket Client to replace Postman
  11. Owncloud – Optionally I have a stopped instance of owncloud. I dont really need it as I could do with an old HDD attached to the pi.
  12. Code Server – Code Editor/IDE. The Visual Studio Code Server replicates the desktop app to the web. It provides most of the features the desktop editor provides.

Additionally to the above installation, we get the following as dependencies. This can be leveraged for development:

  1. Mongo Server
  2. MySQL/MariaDB – With Booksstack
  3. Additionally install PHPMyAdmin to manage MySQL.

Also other databases can be installed. Databases like Postgres could be run.


Rasberry PI Preparation

I have tested this in a Raspberry Pi 4gb and an 8gb, it could as well run in a 2gb version, but we may have to reduce the number of containers we host. To run docker efficiently, it is better to use a 64 bit image. I have used the raspbian beta image, however one can choose the ever so stable ubuntu server 64 for raspberry pi.

Installation Instruction follow this guide – Installing operating system images – Raspberry Pi Documentation

Disable the gui from raspi-config – raspi-config – Raspberry Pi Documentation

sudo apt-get update && sudo apt-get upgrade

I have found an issue with dhcpcd when a lot of virtual networks are added:

https://github.com/raspberrypi/linux/issues/4092

sudo nano /etc/dhcpcd.conf
at the end: denyinterfaces veth*

Setup Docker & Docker Compose

wget -O - https://get.docker.com -o get-docker.sh | sh

Install docker-compose:

sudo apt-get install -y python3 python3-pip
sudo pip3 -v install docker-compose

Topology

I have attached the raspberry pi 4 to the router using a RJ45 cable. Much faster as I host pihole. The Pi can be added as a WiFi device as well.


Install Portainer

The Portainer installation guide – Docker – Documentation (portainer.io). Run it in the Raspberry Pi commandline.

docker volume create portainer_data
docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce

Browse to the URL of Portainer. Below is how it looks with containers.

Portainer also has App Template feature that can be used to deploy repdefined stake.


Add App from Dockerhub

In most cases the install is straight forward. Click on Containers -> Add A new container.

Choose an image with ARM 64. In the above example, we are adding an nginx server in the above. Once added to portainer, the env and storage parameters can be changed by looking at the documentation.


Add App using Docker Compose

Portainer accepts docker-compse and many stacks can be deployed using a docker-compose file.

below the compose file:

---
version: "2"
services:
  bookstack:
    image: ghcr.io/linuxserver/bookstack
    container_name: bookstack
    environment:
      - PUID=1000
      - PGID=1000
      - APP_URL=
      - DB_HOST=bookstack_db
      - DB_USER=bookstack
      - DB_PASS=bookstack
      - DB_DATABASE=bookstackapp
    volumes:
      - /path/to/data:/config
    ports:
      - 9080:80
    restart: unless-stopped
    depends_on:
      - bookstack_db
  bookstack_db:
    image: ghcr.io/linuxserver/mariadb
    container_name: bookstack_db
    environment:
      - PUID=1000
      - PGID=1000
      - MYSQL_ROOT_PASSWORD=root
      - TZ=Europe/London
      - MYSQL_DATABASE=bookstackapp
      - MYSQL_USER=bookstack
      - MYSQL_PASSWORD=bookstack
    volumes:
      - /path/to/data:/config
    ports:
      - 3306:3306
    restart: unless-stopped

Custom Install Apps using Docker Commandline

Requires an advanced understanding of Docker.

A lot of tools may not compile due to the images being built with other platform. The moment there is a “process exec” error, it is probably incompatible with arm 64. In which case the best approach is to rebuild from source using an arm based image.

Portainer automatically will pick up any images added or containers launched.

end.

Best Gifts for Young Kids and their Parents: Raspberry Pi

The Raspberry Pi

If you ever wondered about the gift you would give a young nurturing mind, look no further than the Raspberry Pi.

The Pi as it is commonly called what is a Single Board Computer. They are fully functional computers having the processor, I/O, memory in the same board. For all that, they have a very small form factor. They are powerful enough to automate stuff, create robots, build internet of things or like me build retro consoles or simply be used as desktops.

I usually have a raspberry pi attached to a TV to automate household things and to play games. One particular stuff I do with it is to monitor the house cameras, download the video files, compress them and upload it to to the cloud to have free access from anywhere. The video from the camera is already dumped based on object detection and movement. Perhaps it would be an overkill to add any ML algorithm to it. That is for a later discussion.

Another useful project I have worked on is building a dashcam. Using the Pi Camera, an official add-on. It has taught me great things about image stabilization and picture processing.

It is exlilarating to see a piece of hardware work by running a few lines of code.

Children’s from all age group can enjoy the Pi. However, the raspberry pi is a crude tool designed to be used in so many things. So it is imperative as a gifter, you design the solution, install the necessary software and provide a guide for the parents. The gift works two ways –

  • It helps the parents learn the board and perhaps they will discover something they like.
  • It helps kids with cognitive growth.

The basic Pi with the full Raspbian OS comes with great tools to make hardware work and also tools for children. Raspbian comes out of the box with Scratch which can be used to visually make games and tell stories.

Besides a little older children can start learning python as a first programming language. The ease of the language will be very useful to get them into programming. The Raspberry Pi comes with great python IDEs and tools in itself. For little more advanced usage, PyGame and PyDub can be great teaching tools for visual and audio programming. Minecraft is excellent for coding and gaming.

Requirements

Usually, when I build a Pi, I build it for both parents and kids. Here is a list of things you require:

  • Raspberry Pi 3 or a Raspberry Pi 4
    • Raspberry Pi 3B is a cheap and perfectly capable board. It has 1 GB of RAM and can run the Raspbian OS.
    • Raspberry Pi 4 comes in 2 variations. the 2 GB and the 4 GB versions. These are more powerful and costlier than the Raspberry Pi 3B. The 4GB version is costlier than the 2GB version.
  • A good and cheap controller. Preferably wireless.
  • An SD card preferably 32GB.
  • Power supply for the Raspberry Pi. Power supply for the Raspberry Pi 3 is straightforward – most modern Android Mirco USB will work. The Raspberry Pi 4 is a different ball game. I like to buy the original Raspberry Pi supply for the Pi4. Here is a benchmark comparison for the Raspberry Pis
  • HDMI cable, Keyboard and mouse for the installation. I do not normally include the keyboard and mouse in the gift 🙂
  • A monitor for the installation.
  • ROMs downloaded from the internet for the console of your choice. I have a few – NES, SNES, N64 and my first console – Atari.

Installation instructions:

To not repeat myself, I will link to articles that I followed:

  1. Install the OS image to the SD card. I use Balena Etcher successfully many times.
  2. While you are at it, look for ROMs.
  3. Boot up/Configure the Pi. Install Retropie manually. I prefer the manual method.
  4. Install the ROMs to RetroPie.
  5. Set RetroPie to Autoboot – The games should be autoloaded.
  6. Configure the controller and others.

I prefer the manual installation of RetroPie over Raspbian installation, instead of using the official Retropie images. Even though it is bigger and time-consuming, Retropie can be shut down and the Pi Desktop can be used for other software.

The last step is to market the kit to the parents so that they feel enthusiastic enough to spend the time learning and teaching their kids. The instructions here are only to get you started. This isn’t a complete guide by any chance.

end.