Running for the first time#
Now that you have some configuration, it’s time to run it. The above configuration should have had you either create a directory or use a particular directory for configuration. Let’s change our directory to that now if you aren’t already there.
cd <THE DIRECTORY YOU USED IN PREVIOUS STEPS>
Your working directory should contain docker-compose.yml
.
Here is an example of what the file structure might look like at this point in the configuration process:
~/Documents/containers/solarthing/
├── main/
│ └── config/
│ └── base.json
└── docker-compose.yml
In this example, the working directory should be ~/Documents/containers/solarthing
.
Assuming you have just configured a program to monitor a serial port, you will need to add a few lines to your docker-compose.yml
.
Make sure you add the cap_add
and devices
sections so it looks like the highlighted lines below.
Please change /dev/ttyUSB0:/dev/ttyUSB0
to reflect the path to the serial port if it is different.
For instance, if your serial port is /dev/ttyUSB1
, you should instead use /dev/ttyUSB1:/dev/ttyUSB1
services:
main:
image: 'ghcr.io/wildmountainfarms/solarthing:latest'
container_name: solarthing-main
restart: 'unless-stopped'
command: run --base config/base.json
group_add: # this is only necessary if you are using a user other than root
- dialout
cap_add:
- SYS_RAWIO
devices:
- '/dev/ttyUSB0:/dev/ttyUSB0'
volumes:
- './main/config:/app/config:ro'
- './main/logs:/app/logs'
Now run:
sudo docker compose up
OK, now our shell should look something like this (custom_rover
may be different):
pi@raspberrypi:/opt/solarthing/program/custom_rover$
Now, all we have to do is run this:
sudo -u solarthing ./run.sh
Using sudo -u solarthing ...
makes sure that the log files generated by SolarThing have correct file system ownership.
The program should start up and it will start outputting lots of messages to your screen. If you configured it correctly, after a second you will see
data from your device in a JSON format. Press CTRL+C
to stop the program.