Webserver basics - RPI3

Hello,

I plan to set up a few raspberry pis with pikrellcam GitHub - billw2/pikrellcam: Raspberry Pi motion vector detection program with OSD web interface.. I have managed to set up a pi with Debian and install/run pikrellcam with the BalenaOS and hub. I can navigate the pi with a terminal so know it is working.

Pikrellcam usually creates a nginx webserver on the localhost on port 80. However whilst using the balenaOS/ container I cannot access this locally hosted webpage.

My dockerfile is setup like this
FROM balenalib/%%BALENA_MACHINE_NAME%%-debian-node:10-buster

COPY /pikrellcam /home/pi/pikrellcam

WORKDIR /home/pi/pikrellcam

RUN bash install-pikrellcam.sh

CMD ["./pikrellcam"]

Is there anything obvious I need to do to access the webpage. I have a feeling it is something to do with port forwarding but I am not an expert,

Thanks for any support, it’s appreciated!
Sam

Hey there @tennisparty and welcome to the forums!

Just a few clarification questions first as you’ve said “I have managed to set up a pi with Debian”; did you do a bare metal install of Debian and build on top of that? Alternatively did you install balenaOS as a download from balenaCloud (and now have the device showing online in the balenaCloud dashboard)?

Next, are you running this container as part of a multicontainer application (using a docker-compose.yml file), or as one single standalone container? If you’re just running one container on it’s own you shouldn’t have to do anything to expose port 80 externally to the device. You can check here for a basic example of a webserver running on port 80, and as you can see no special consideration is given to get it to work.

However if the container is part of a multicontainer application, you’ll need to add port 80 to the list of ports for that service within the compose file. See here for an example of that.

Aside from all this, the project looks great and if you can get it up and running we’d love to see it listed on balenaHub :slight_smile:

Another further idea; you could also run something like netstat -tlp to check that the app is running and actually listening on port 80 :slight_smile:

Hello

Just wondering if the suggestions my colleague made were helpful? Were you able to get this working?

Let us know. thanks :slight_smile:

Hi Rahul,

I never got it working with a single container application even when exposing port 80. I managed to run a multicontainer application which seemed to expose the port (although I haven’t tested extensively so can’t be certain). I then got an error regarding the raspberry pi camera so need to work on that error, I found some forums online with similar errors so should be able to sort that. I’ve been moving house but will get back to you when I get as chance to look at it. I appreciate your help,

Thanks
Sam

Thanks for the update

I then got an error regarding the raspberry pi camera so need to work on that error, I found some forums online with similar errors so should be able to sort that

When working with the camera make sure to set the proper settings. You can find out more here.

Keep us posted

Thanks

Thanks, I just checked my notes, it was the camera permissions which I had problems with. I am going to try the instructions on here How to Access the Raspberry Pi Camera in Docker

@tennisparty I just wanted to reach out and see if the link helped you resolve the issue? #pendinguserresponse

Hi all,

Thanks for your help. I have managed to get a version of Pikrellcam working in a container with the variables you listed. I have managed to run the Pikrellcam install script in the dockerfile.template and then start Pikrellcam in the container with CMD. However… the Pikrellcam install script installs Nginx and Php7.3 to serve the web application. To get Pikrellcam to start running a webserver container to work I have to enter the container terminal and start both of these services.

I understand it is best practice to split out such elements into different containers. As such I have tried separating the PHP installation into another container but I am getting a bit stuck on how to go about this. I have setup another container with the following php image “php:7.3-fpm”. But… I don’t know how to connect this to the Pikrellcam container I have setup. I have tried googling for how to set this up but am very lost.

Any help would be much appreciated!

Thanks,
Sam

Hello,
you’re right, that this is best practice, but unfortunately with software that hasn’t been developed with containers in mind it’s often not worth the effort.
As you’re main problem you seem to have now is that you need to start multiple applications inside your container I would suggest you’re using something like this:

You set this as your ENTRYPOINT in your Dockerfile and have a small config that defines what programs to keep running.
Hope this helps!