Browse Source

rpicamera: allow to use the Raspberry Pi Camera with Docker (#1212)

pull/1233/head v0.20.2
Alessandro Ros 3 years ago committed by GitHub
parent
commit
4c96a6873e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .dockerignore
  2. 2
      .github/workflows/release.yml
  3. 28
      README.md
  4. 65
      scripts/dockerhub.mk

1
.dockerignore

@ -1,6 +1,5 @@
# do not add .git, since it is needed to extract the tag # do not add .git, since it is needed to extract the tag
/tmp /tmp
/binaries
/coverage*.txt /coverage*.txt
/apidocs/*.html /apidocs/*.html

2
.github/workflows/release.yml

@ -66,6 +66,8 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- run: make binaries
- run: make dockerhub - run: make dockerhub
env: env:
DOCKER_USER: ${{ secrets.DOCKER_USER }} DOCKER_USER: ${{ secrets.DOCKER_USER }}

28
README.md

@ -525,19 +525,15 @@ After starting the server, the webcam can be reached on `rtsp://localhost:8554/c
### From a Raspberry Pi Camera ### From a Raspberry Pi Camera
_rtsp-simple-server_ natively support the Raspberry Pi Camera, enabling high-quality and low-latency video streaming from the camera to any user. To make the video stream of a Raspberry Pi Camera available on the server: _rtsp-simple-server_ natively support the Raspberry Pi Camera, enabling high-quality and low-latency video streaming from the camera to any user. There are a couple of requisites:
1. The server must be installed on a Raspberry Pi, with Raspberry Pi OS bullseye or newer as operative system, and must be installed by using the standard method (Docker is not actually supported). If you're using the 64-bit version of the operative system, you need to pick the `arm64` variant of the server. 1. The server must run on a Raspberry Pi, with Raspberry Pi OS bullseye or newer as operative system.
2. Make sure that the legacy camera stack is disabled. Type: 2. Make sure that the legacy camera stack is disabled. Type `sudo raspi-config`, then go to `Interfacing options`, `enable/disable legacy camera support`, choose `no`. Reboot the system.
``` 3. Make sure that the `libcamera` version is at least `0.0.1`, otherwise upgrade it with `sudo apt upgrade`.
sudo raspi-config
```
Then go to `Interfacing options`, `enable/disable legacy camera support`, choose `no`. Reboot the system. If you want to run the standard (non-dockerized) version of the server, just download the server executable and make sure to pick the `arm64` variant if you're using the 64-bit version of the operative system. Then edit `rtsp-simple-server.yml` and replace everything inside section `paths` with the following content:
3. edit `rtsp-simple-server.yml` and replace everything inside section `paths` with the following content:
```yml ```yml
paths: paths:
@ -545,6 +541,20 @@ _rtsp-simple-server_ natively support the Raspberry Pi Camera, enabling high-qua
source: rpiCamera source: rpiCamera
``` ```
If you want to run the server with Docker, you need to use the `--privileged` flag and expose some folders:
```
docker run --rm -it \
--network=host \
--privileged \
--tmpfs /dev/shm:exec \
-v /usr:/usr:ro \
-v /lib:/lib:ro \
-v /run/udev:/run/udev:ro \
-e RTSP_PATHS_CAM_SOURCE=rpiCamera \
aler9/rtsp-simple-server
```
After starting the server, the camera can be reached on `rtsp://raspberry-pi:8554/cam` or `http://raspberry-pi:8888/cam`. After starting the server, the camera can be reached on `rtsp://raspberry-pi:8554/cam` or `http://raspberry-pi:8888/cam`.
Camera settings can be changed by using the `rpiCamera*` parameters: Camera settings can be changed by using the `rpiCamera*` parameters:

65
scripts/dockerhub.mk

@ -1,18 +1,7 @@
define DOCKERFILE_DOCKERHUB define DOCKERFILE_DOCKERHUB
FROM --platform=linux/amd64 $(BASE_IMAGE) AS build
RUN apk add --no-cache git
WORKDIR /s
COPY go.mod go.sum ./
RUN go mod download
COPY . ./
ARG VERSION
ARG OPTS
RUN export CGO_ENABLED=0 $${OPTS} \
&& go build -ldflags "-X github.com/aler9/rtsp-simple-server/internal/core.version=$$VERSION" -o /rtsp-simple-server
FROM scratch FROM scratch
COPY --from=build /rtsp-simple-server / ARG BINARY
COPY --from=build /s/rtsp-simple-server.yml / ADD $$BINARY /
ENTRYPOINT [ "/rtsp-simple-server" ] ENTRYPOINT [ "/rtsp-simple-server" ]
endef endef
export DOCKERFILE_DOCKERHUB export DOCKERFILE_DOCKERHUB
@ -27,34 +16,38 @@ dockerhub:
rm -rf $$HOME/.docker/manifests/* rm -rf $$HOME/.docker/manifests/*
docker buildx create --name=builder --use docker buildx create --name=builder --use
echo "$$DOCKERFILE_DOCKERHUB" | docker buildx build . -f - --build-arg VERSION=$(VERSION) \ echo "$$DOCKERFILE_DOCKERHUB" | docker buildx build . -f - \
--push -t aler9/rtsp-simple-server:$(VERSION)-amd64 --build-arg OPTS="GOOS=linux GOARCH=amd64" --platform=linux/amd64 --platform=linux/amd64 \
--build-arg BINARY="$$(echo binaries/*linux_amd64.tar.gz)" \
echo "$$DOCKERFILE_DOCKERHUB" | docker buildx build . -f - --build-arg VERSION=$(VERSION) \ -t aler9/rtsp-simple-server:$(VERSION)-amd64 \
--push -t aler9/rtsp-simple-server:$(VERSION)-armv6 --build-arg OPTS="GOOS=linux GOARCH=arm GOARM=6" --platform=linux/arm/v6 -t aler9/rtsp-simple-server:latest-amd64 \
--push
echo "$$DOCKERFILE_DOCKERHUB" | docker buildx build . -f - --build-arg VERSION=$(VERSION) \
--push -t aler9/rtsp-simple-server:$(VERSION)-armv7 --build-arg OPTS="GOOS=linux GOARCH=arm GOARM=7" --platform=linux/arm/v7 echo "$$DOCKERFILE_DOCKERHUB" | docker buildx build . -f - \
--platform=linux/arm/v6 \
echo "$$DOCKERFILE_DOCKERHUB" | docker buildx build . -f - --build-arg VERSION=$(VERSION) \ --build-arg BINARY="$$(echo binaries/*linux_armv6.tar.gz)" \
--push -t aler9/rtsp-simple-server:$(VERSION)-arm64v8 --build-arg OPTS="GOOS=linux GOARCH=arm64" --platform=linux/arm64/v8 -t aler9/rtsp-simple-server:$(VERSION)-armv6 \
-t aler9/rtsp-simple-server:latest-armv6 \
--push
echo "$$DOCKERFILE_DOCKERHUB" | docker buildx build . -f - \
--platform=linux/arm/v7 \
--build-arg BINARY="$$(echo binaries/*linux_armv7.tar.gz)" \
-t aler9/rtsp-simple-server:$(VERSION)-armv7 \
-t aler9/rtsp-simple-server:latest-armv7 \
--push
echo "$$DOCKERFILE_DOCKERHUB" | docker buildx build . -f - \
--platform=linux/arm64/v8 \
--build-arg BINARY="$$(echo binaries/*linux_arm64v8.tar.gz)" \
-t aler9/rtsp-simple-server:$(VERSION)-arm64v8 \
-t aler9/rtsp-simple-server:latest-arm64v8 \
--push
docker manifest create aler9/rtsp-simple-server:$(VERSION) \ docker manifest create aler9/rtsp-simple-server:$(VERSION) \
$(foreach ARCH,amd64 armv6 armv7 arm64v8,aler9/rtsp-simple-server:$(VERSION)-$(ARCH)) $(foreach ARCH,amd64 armv6 armv7 arm64v8,aler9/rtsp-simple-server:$(VERSION)-$(ARCH))
docker manifest push aler9/rtsp-simple-server:$(VERSION) docker manifest push aler9/rtsp-simple-server:$(VERSION)
docker manifest create aler9/rtsp-simple-server:latest-amd64 aler9/rtsp-simple-server:$(VERSION)-amd64
docker manifest push aler9/rtsp-simple-server:latest-amd64
docker manifest create aler9/rtsp-simple-server:latest-armv6 aler9/rtsp-simple-server:$(VERSION)-armv6
docker manifest push aler9/rtsp-simple-server:latest-armv6
docker manifest create aler9/rtsp-simple-server:latest-armv7 aler9/rtsp-simple-server:$(VERSION)-armv7
docker manifest push aler9/rtsp-simple-server:latest-armv7
docker manifest create aler9/rtsp-simple-server:latest-arm64v8 aler9/rtsp-simple-server:$(VERSION)-arm64v8
docker manifest push aler9/rtsp-simple-server:latest-arm64v8
docker manifest create aler9/rtsp-simple-server:latest \ docker manifest create aler9/rtsp-simple-server:latest \
$(foreach ARCH,amd64 armv6 armv7 arm64v8,aler9/rtsp-simple-server:$(VERSION)-$(ARCH)) $(foreach ARCH,amd64 armv6 armv7 arm64v8,aler9/rtsp-simple-server:$(VERSION)-$(ARCH))
docker manifest push aler9/rtsp-simple-server:latest docker manifest push aler9/rtsp-simple-server:latest

Loading…
Cancel
Save