-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #731 from ZyanKLee/feature/testenv-dockerfile
Dockerfile for easier testing with docker
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |