mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-12-24 11:51:18 +08:00
support customizing official Docker images (#4471)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
# do not add .git, since it is needed to extract the tag
|
||||
# do not add /tmp, since it is needed by make dockerhub
|
||||
/binaries
|
||||
# do not add /binaries, since it is needed by Docker images
|
||||
/coverage*.txt
|
||||
/apidocs/*.html
|
||||
/internal/core/VERSION
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,3 @@
|
||||
/tmp
|
||||
/binaries
|
||||
/coverage*.txt
|
||||
/apidocs/*.html
|
||||
|
||||
3
Makefile
3
Makefile
@@ -1,9 +1,6 @@
|
||||
BASE_IMAGE = golang:1.23-alpine3.20
|
||||
LINT_IMAGE = golangci/golangci-lint:v1.64.5
|
||||
NODE_IMAGE = node:20-alpine3.20
|
||||
ALPINE_IMAGE = alpine:3.20
|
||||
RPI32_IMAGE = balenalib/raspberry-pi:bullseye-run-20240508
|
||||
RPI64_IMAGE = balenalib/raspberrypi3-64:bullseye-run-20240429
|
||||
|
||||
.PHONY: $(shell ls)
|
||||
|
||||
|
||||
19
README.md
19
README.md
@@ -157,6 +157,7 @@ _rtsp-simple-server_ has been rebranded as _MediaMTX_. The reason is pretty obvi
|
||||
* [Custom libcamera](#custom-libcamera)
|
||||
* [Cross compile](#cross-compile)
|
||||
* [Compile for all supported platforms](#compile-for-all-supported-platforms)
|
||||
* [Docker image](#docker-image-1)
|
||||
* [License](#license)
|
||||
* [Specifications](#specifications)
|
||||
* [Related projects](#related-projects)
|
||||
@@ -2574,6 +2575,24 @@ make binaries
|
||||
|
||||
The command will produce tarballs in folder `binaries/`.
|
||||
|
||||
### Docker image
|
||||
|
||||
The official Docker image can be recompiled by following these steps:
|
||||
|
||||
1. Build binaries for all supported platforms:
|
||||
|
||||
```sh
|
||||
make binaries
|
||||
```
|
||||
|
||||
2. Build the image by using one of the Dockerfiles inside the `docker/` folder:
|
||||
|
||||
```
|
||||
docker build . -f docker/standard.Dockerfile -t my-mediamtx
|
||||
```
|
||||
|
||||
A Dockerfile is available for each image variant (`standard.Dockerfile`, `ffmpeg.Dockerfile`, `rpi.Dockerfile`, `ffmpeg-rpi.Dockerfile`).
|
||||
|
||||
## License
|
||||
|
||||
All the code in this repository is released under the [MIT License](LICENSE). Compiled binaries include some third-party dependencies:
|
||||
|
||||
33
docker/ffmpeg-rpi.Dockerfile
Normal file
33
docker/ffmpeg-rpi.Dockerfile
Normal file
@@ -0,0 +1,33 @@
|
||||
#################################################################
|
||||
FROM --platform=linux/amd64 scratch AS binaries
|
||||
|
||||
ADD binaries/mediamtx_*_linux_armv6.tar.gz /linux/arm/v6
|
||||
ADD binaries/mediamtx_*_linux_armv7.tar.gz /linux/arm/v7
|
||||
ADD binaries/mediamtx_*_linux_arm64v8.tar.gz /linux/arm64
|
||||
|
||||
#################################################################
|
||||
|
||||
FROM --platform=linux/arm/v6 balenalib/raspberry-pi:bullseye-run-20240508 AS base-arm-v6
|
||||
FROM --platform=linux/arm/v7 balenalib/raspberry-pi:bullseye-run-20240508 AS base-arm-v7
|
||||
FROM --platform=linux/arm64 balenalib/raspberrypi3-64:bullseye-run-20240429 AS base-arm64
|
||||
|
||||
#################################################################
|
||||
FROM --platform=linux/amd64 scratch AS base
|
||||
|
||||
COPY --from=base-arm-v6 / /linux/arm/v6
|
||||
COPY --from=base-arm-v7 / /linux/arm/v7
|
||||
COPY --from=base-arm64 / /linux/arm64
|
||||
|
||||
#################################################################
|
||||
FROM scratch
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
COPY --from=base /$TARGETPLATFORM /
|
||||
|
||||
RUN apt update \
|
||||
&& apt install -y --no-install-recommends ffmpeg \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=binaries /$TARGETPLATFORM /
|
||||
|
||||
ENTRYPOINT [ "/mediamtx" ]
|
||||
17
docker/ffmpeg.Dockerfile
Normal file
17
docker/ffmpeg.Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
||||
#################################################################
|
||||
FROM --platform=linux/amd64 scratch AS binaries
|
||||
|
||||
ADD binaries/mediamtx_*_linux_amd64.tar.gz /linux/amd64
|
||||
ADD binaries/mediamtx_*_linux_armv6.tar.gz /linux/arm/v6
|
||||
ADD binaries/mediamtx_*_linux_armv7.tar.gz /linux/arm/v7
|
||||
ADD binaries/mediamtx_*_linux_arm64v8.tar.gz /linux/arm64
|
||||
|
||||
#################################################################
|
||||
FROM alpine:3.20
|
||||
|
||||
RUN apk add --no-cache ffmpeg
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
COPY --from=binaries /$TARGETPLATFORM /
|
||||
|
||||
ENTRYPOINT [ "/mediamtx" ]
|
||||
29
docker/rpi.Dockerfile
Normal file
29
docker/rpi.Dockerfile
Normal file
@@ -0,0 +1,29 @@
|
||||
#################################################################
|
||||
FROM --platform=linux/amd64 scratch AS binaries
|
||||
|
||||
ADD binaries/mediamtx_*_linux_armv6.tar.gz /linux/arm/v6
|
||||
ADD binaries/mediamtx_*_linux_armv7.tar.gz /linux/arm/v7
|
||||
ADD binaries/mediamtx_*_linux_arm64v8.tar.gz /linux/arm64
|
||||
|
||||
#################################################################
|
||||
|
||||
FROM --platform=linux/arm/v6 balenalib/raspberry-pi:bullseye-run-20240508 AS base-arm-v6
|
||||
FROM --platform=linux/arm/v7 balenalib/raspberry-pi:bullseye-run-20240508 AS base-arm-v7
|
||||
FROM --platform=linux/arm64 balenalib/raspberrypi3-64:bullseye-run-20240429 AS base-arm64
|
||||
|
||||
#################################################################
|
||||
FROM --platform=linux/amd64 scratch AS base
|
||||
|
||||
COPY --from=base-arm-v6 / /linux/arm/v6
|
||||
COPY --from=base-arm-v7 / /linux/arm/v7
|
||||
COPY --from=base-arm64 / /linux/arm64
|
||||
|
||||
#################################################################
|
||||
FROM scratch
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
COPY --from=base /$TARGETPLATFORM /
|
||||
|
||||
COPY --from=binaries /$TARGETPLATFORM /
|
||||
|
||||
ENTRYPOINT [ "/mediamtx" ]
|
||||
15
docker/standard.Dockerfile
Normal file
15
docker/standard.Dockerfile
Normal file
@@ -0,0 +1,15 @@
|
||||
#################################################################
|
||||
FROM --platform=linux/amd64 scratch AS binaries
|
||||
|
||||
ADD binaries/mediamtx_*_linux_amd64.tar.gz /linux/amd64
|
||||
ADD binaries/mediamtx_*_linux_armv6.tar.gz /linux/arm/v6
|
||||
ADD binaries/mediamtx_*_linux_armv7.tar.gz /linux/arm/v7
|
||||
ADD binaries/mediamtx_*_linux_arm64v8.tar.gz /linux/arm64
|
||||
|
||||
#################################################################
|
||||
FROM scratch
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
COPY --from=binaries /$TARGETPLATFORM /
|
||||
|
||||
ENTRYPOINT [ "/mediamtx" ]
|
||||
@@ -67,7 +67,7 @@ endef
|
||||
export DOCKERFILE_BINARIES
|
||||
|
||||
binaries:
|
||||
echo "$$DOCKERFILE_BINARIES" | DOCKER_BUILDKIT=1 docker build . -f - \
|
||||
echo "$$DOCKERFILE_BINARIES" | docker build . -f - \
|
||||
-t temp
|
||||
docker run --rm -v "$(shell pwd):/out" \
|
||||
temp sh -c "rm -rf /out/binaries && cp -r /s/binaries /out/"
|
||||
|
||||
@@ -1,106 +1,39 @@
|
||||
DOCKER_REPOSITORY = bluenviron/mediamtx
|
||||
|
||||
define DOCKERFILE_DOCKERHUB
|
||||
FROM scratch
|
||||
ARG TARGETPLATFORM
|
||||
ADD tmp/binaries/$$TARGETPLATFORM.tar.gz /
|
||||
ENTRYPOINT [ "/mediamtx" ]
|
||||
endef
|
||||
export DOCKERFILE_DOCKERHUB
|
||||
|
||||
define DOCKERFILE_DOCKERHUB_FFMPEG
|
||||
FROM $(ALPINE_IMAGE)
|
||||
RUN apk add --no-cache ffmpeg
|
||||
ARG TARGETPLATFORM
|
||||
ADD tmp/binaries/$$TARGETPLATFORM.tar.gz /
|
||||
ENTRYPOINT [ "/mediamtx" ]
|
||||
endef
|
||||
export DOCKERFILE_DOCKERHUB_FFMPEG
|
||||
|
||||
define DOCKERFILE_DOCKERHUB_RPI_BASE_32
|
||||
FROM $(RPI32_IMAGE)
|
||||
endef
|
||||
export DOCKERFILE_DOCKERHUB_RPI_BASE_32
|
||||
|
||||
define DOCKERFILE_DOCKERHUB_RPI_BASE_64
|
||||
FROM $(RPI64_IMAGE)
|
||||
endef
|
||||
export DOCKERFILE_DOCKERHUB_RPI_BASE_64
|
||||
|
||||
define DOCKERFILE_DOCKERHUB_RPI
|
||||
FROM scratch
|
||||
ARG TARGETPLATFORM
|
||||
ADD tmp/rpi_base/$$TARGETPLATFORM.tar /
|
||||
ADD tmp/binaries/$$TARGETPLATFORM.tar.gz /
|
||||
ENTRYPOINT [ "/mediamtx" ]
|
||||
endef
|
||||
export DOCKERFILE_DOCKERHUB_RPI
|
||||
|
||||
define DOCKERFILE_DOCKERHUB_FFMPEG_RPI
|
||||
FROM scratch
|
||||
ARG TARGETPLATFORM
|
||||
ADD tmp/rpi_base/$$TARGETPLATFORM.tar /
|
||||
RUN apt update && apt install -y --no-install-recommends ffmpeg && rm -rf /var/lib/apt/lists/*
|
||||
ADD tmp/binaries/$$TARGETPLATFORM.tar.gz /
|
||||
ENTRYPOINT [ "/mediamtx" ]
|
||||
endef
|
||||
export DOCKERFILE_DOCKERHUB_FFMPEG_RPI
|
||||
|
||||
dockerhub:
|
||||
$(eval VERSION := $(shell git describe --tags | tr -d v))
|
||||
|
||||
docker login -u $(DOCKER_USER) -p $(DOCKER_PASSWORD)
|
||||
|
||||
rm -rf tmp
|
||||
mkdir -p tmp tmp/binaries/linux/arm tmp/rpi_base/linux/arm
|
||||
|
||||
cp binaries/*linux_amd64.tar.gz tmp/binaries/linux/amd64.tar.gz
|
||||
cp binaries/*linux_armv6.tar.gz tmp/binaries/linux/arm/v6.tar.gz
|
||||
cp binaries/*linux_armv7.tar.gz tmp/binaries/linux/arm/v7.tar.gz
|
||||
cp binaries/*linux_arm64v8.tar.gz tmp/binaries/linux/arm64.tar.gz
|
||||
|
||||
docker buildx rm builder 2>/dev/null || true
|
||||
rm -rf "$$HOME/.docker/manifests"/*
|
||||
docker buildx create --name=builder --use
|
||||
docker buildx create --name=builder
|
||||
|
||||
echo "$$DOCKERFILE_DOCKERHUB_RPI_BASE_32" | docker buildx build . -f - \
|
||||
--provenance=false \
|
||||
--platform=linux/arm/v6 \
|
||||
--output type=tar,dest=tmp/rpi_base/linux/arm/v6.tar
|
||||
cp tmp/rpi_base/linux/arm/v6.tar tmp/rpi_base/linux/arm/v7.tar
|
||||
|
||||
echo "$$DOCKERFILE_DOCKERHUB_RPI_BASE_64" | docker buildx build . -f - \
|
||||
--provenance=false \
|
||||
--platform=linux/arm64/v8 \
|
||||
--output type=tar,dest=tmp/rpi_base/linux/arm64.tar
|
||||
|
||||
echo "$$DOCKERFILE_DOCKERHUB_FFMPEG_RPI" | docker buildx build . -f - \
|
||||
--provenance=false \
|
||||
--platform=linux/arm/v6,linux/arm/v7,linux/arm64/v8 \
|
||||
docker build --builder=builder \
|
||||
-f docker/ffmpeg-rpi.Dockerfile . \
|
||||
--platform=linux/arm/v6,linux/arm/v7,linux/arm64 \
|
||||
-t $(DOCKER_REPOSITORY):$(VERSION)-ffmpeg-rpi \
|
||||
-t $(DOCKER_REPOSITORY):latest-ffmpeg-rpi \
|
||||
--push
|
||||
|
||||
echo "$$DOCKERFILE_DOCKERHUB_RPI" | docker buildx build . -f - \
|
||||
--provenance=false \
|
||||
--platform=linux/arm/v6,linux/arm/v7,linux/arm64/v8 \
|
||||
docker build --builder=builder \
|
||||
-f docker/rpi.Dockerfile . \
|
||||
--platform=linux/arm/v6,linux/arm/v7,linux/arm64 \
|
||||
-t $(DOCKER_REPOSITORY):$(VERSION)-rpi \
|
||||
-t $(DOCKER_REPOSITORY):latest-rpi \
|
||||
--push
|
||||
|
||||
echo "$$DOCKERFILE_DOCKERHUB_FFMPEG" | docker buildx build . -f - \
|
||||
--provenance=false \
|
||||
--platform=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8 \
|
||||
docker build --builder=builder \
|
||||
-f docker/ffmpeg.Dockerfile . \
|
||||
--platform=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 \
|
||||
-t $(DOCKER_REPOSITORY):$(VERSION)-ffmpeg \
|
||||
-t $(DOCKER_REPOSITORY):latest-ffmpeg \
|
||||
--push
|
||||
|
||||
echo "$$DOCKERFILE_DOCKERHUB" | docker buildx build . -f - \
|
||||
--provenance=false \
|
||||
--platform=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8 \
|
||||
docker build --builder=builder \
|
||||
-f docker/standard.Dockerfile . \
|
||||
--platform=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 \
|
||||
-t $(DOCKER_REPOSITORY):$(VERSION) \
|
||||
-t $(DOCKER_REPOSITORY):latest \
|
||||
--push
|
||||
|
||||
docker buildx rm builder
|
||||
rm -rf "$$HOME/.docker/manifests"/*
|
||||
|
||||
Reference in New Issue
Block a user