mediamtx/scripts/dockerhub.mk
Johnny Arcitec 426e6f89a2
improve unsafe path handling (#3927)
* fix: improve unsafe path handling

Paths containing spaces or dashes were being interpreted as separate options, since the path handling lacked double quotes.

This fixes all unsafe instances of "PWD" and "HOME", along with all other unsafe paths in the scripts.

* readme: explicitly mount the configuration as read-only

This clearly shows users that the MediaMTX container will not modify the configuration file.
2024-11-06 15:15:25 +01:00

107 lines
3.1 KiB
Makefile

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
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 \
-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 \
-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 \
-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 \
-t $(DOCKER_REPOSITORY):$(VERSION) \
-t $(DOCKER_REPOSITORY):latest \
--push
docker buildx rm builder
rm -rf "$$HOME/.docker/manifests"/*