Testing the node package
The Docker folder of the repository is a good starting point for sandboxed environments. For a simpler setup, this Arch Linux image installs the node’s Python dependencies with pacman only (no pip) and adds the ethoscope package repository, so that the ethoscope-node package can be installed and tested in a throwaway container.
The repository’s packages are signed. The Dockerfile imports the repository’s public key, trusts only the key with the fingerprint below, and requires valid signatures on packages (see the Arch package for the same steps on a real node).
# sandbox.dockerfile: Arch Linux with the node's dependencies from pacman (no pip)# Build with: docker build -f sandbox.dockerfile -t sandbox:latest .FROM archlinux:latest
# Update the system and install base-devel and gitRUN pacman -Sy \ && pacman-key --init \ && pacman-key --populate archlinux \ && pacman -S --noconfirm archlinux-keyring \ && pacman -Syu --needed --noconfirm base-devel git micro nano
# Python dependencies of src/node and src/ethoscope, from pacman onlyRUN pacman -Sy --needed --noconfirm \ python \ python-bottle \ python-cherrypy \ python-mysql-connector \ python-netifaces \ python-gitpython \ python-zeroconf \ python-numpy \ python-opencv \ python-pyserial \ python-psutil \ python-requests \ python-scipy \ python-dateutil
# Trust the ethoscope repository's signing key and add the repositoryRUN curl -fsSL -o /tmp/ethoscope-repo-key.asc https://repo.ethoscope.lab.gilest.ro/ethoscope-repo-key.asc \ && gpg --show-keys --with-colons /tmp/ethoscope-repo-key.asc | grep -q '^fpr:::::::::6BA661B1A1988DDF50BF7F2ADE7F773BDE8D92BF:' \ && pacman-key --add /tmp/ethoscope-repo-key.asc \ && pacman-key --lsign-key 6BA661B1A1988DDF50BF7F2ADE7F773BDE8D92BF \ && printf '\n[ethoscope]\nSigLevel = Required DatabaseOptional\nServer = https://repo.ethoscope.lab.gilest.ro/\n' >> /etc/pacman.conf \ && pacman -Sy
# makepkg cannot run as root: create a user for building AUR packagesRUN useradd -m -G wheel -s /bin/bash sandbox && \ echo "sandbox ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# python-mattermostdriver from the AURUSER sandboxWORKDIR /home/sandboxRUN git clone https://aur.archlinux.org/python-mattermostdriver.git && \ cd python-mattermostdriver && \ makepkg -si --noconfirm
USER rootWORKDIR /rootCMD ["/bin/bash"]Build it:
docker build -f sandbox.dockerfile -t sandbox:latest .Open a shell in the container, with port 9000 of the host mapped to port 80 of the container:
docker run -it --publish 9000:80 --rm sandbox:latest /bin/bashOr test an installation of the node package directly:
docker run -it --publish 9000:80 --rm sandbox:latest pacman -Sy ethoscope-node