Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile for easier testing with docker #731

Merged
merged 3 commits into from
Jan 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.