Skip to content

Commit

Permalink
Merge pull request #731 from ZyanKLee/feature/testenv-dockerfile
Browse files Browse the repository at this point in the history
Dockerfile for easier testing with docker
  • Loading branch information
MiczFlor authored Jan 18, 2020
2 parents 1c78165 + f29dfe6 commit dbf0bc5
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
27 changes: 27 additions & 0 deletions ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM arm32v7/debian:buster-slim

COPY . /code
WORKDIR /code

RUN groupadd --gid 1000 pi ;\
useradd -u 1000 -g 1000 -G sudo -d /home/pi -m -s /bin/bash -p '$1$iV7TOwOe$6ojkJQXyEA9bHd/SqNLNj0' pi ;\
chown -R 1000:1000 /code /home/pi ;\
chmod +x /code/scripts/installscripts/buster-install-default.sh

RUN apt-get update ;\
apt-get -y install curl gnupg sudo ;\
echo 'deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi' > /etc/apt/sources.list ;\
echo 'deb http://archive.raspberrypi.org/debian/ buster main' > /etc/apt/sources.list.d/raspi.list ;\
curl http://raspbian.raspberrypi.org/raspbian.public.key | apt-key add - ;\
curl http://archive.raspberrypi.org/debian/raspberrypi.gpg.key | apt-key add - ;\
echo 'pi ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/pi ;\
apt-get clean ;\
rm -rf /var/cache/apt/* /var/lib/apt/lists/*

RUN apt-get update ;\
apt-get -y dist-upgrade --auto-remove --purge ;\
apt-get -y install python3-pip wget build-essential git iw locales ;\
apt-get clean ;\
rm -rf /var/cache/apt/* /var/lib/apt/lists/*

USER pi
47 changes: 47 additions & 0 deletions ci/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Docker Test-Environment

Having to re-flash the sd card of their raspberry pi did annoy ZyanKLee that much he created
this little set of tools to allow testing without flashing.

This is a work in progress so expect things to fail or being flaky.

## Howto

* First you need a raspberry pi with some decent performance (RPi 3 or 4 would be recommended)
* Flash its sd card with raspbian buster lite
* use raspi-config to resize the filesystem to the whole sd card (menu: 7 -> A1)
* install some tools and reboot:
sudo apt-get update
sudo apt-get -y dist-upgrade
sudo apt-get -y install docker.io git
sudo gpasswd -a pi docker
sudo reboot
* login to your RPi
* clone this repo and cd into its local clone:
git clone https://github.com/MiczFlor/RPi-Jukebox-RFID.git
cd RPi-Jukebox-RFID/
* build the docker image:
docker build -t rpi-jukebox-rfid:latest -f ci/Dockerfile .
* get something to drink or eat
* run the freshly built docker image and start testing. For example:
docker run --rm -ti rpi-jukebox-rfid:latest /bin/bash
./scripts/installscripts/buster-install-default.sh


NOTE: Get familiar with docker and its flags - `--rm` for example will remove the
container after you log out of it and all changes will be lost.


### mount hosts code as volume

The created image now contains all the code in the directory `/code` - if you do not want to
rebuild the image after each code-change you can 'mount' the RPi's code version into the
container:

git clone https://github.com/MiczFlor/RPi-Jukebox-RFID.git
cd RPi-Jukebox-RFID/
docker build -t rpi-jukebox-rfid:latest -f ci/Dockerfile .
docker run --rm -ti -v $PWD:/code rpi-jukebox-rfid:latest /bin/bash

In that way every change to the code in the container will be available on the RPi as well
as vice versa.

0 comments on commit dbf0bc5

Please sign in to comment.