2023-08-07 18:25:45 +00:00
|
|
|
BINARY_NAME = mediamtx
|
|
|
|
|
2022-09-17 18:15:23 +00:00
|
|
|
define DOCKERFILE_BINARIES
|
2023-05-15 07:52:56 +00:00
|
|
|
FROM $(BASE_IMAGE) AS build-base
|
2022-08-23 07:42:25 +00:00
|
|
|
RUN apk add --no-cache zip make git tar
|
|
|
|
WORKDIR /s
|
|
|
|
COPY go.mod go.sum ./
|
|
|
|
RUN go mod download
|
|
|
|
COPY . ./
|
|
|
|
ENV CGO_ENABLED 0
|
2023-06-07 10:26:08 +00:00
|
|
|
RUN rm -rf tmp binaries
|
2022-09-17 18:15:23 +00:00
|
|
|
RUN mkdir tmp binaries
|
2023-04-01 17:32:10 +00:00
|
|
|
RUN cp mediamtx.yml LICENSE tmp/
|
2024-02-11 23:31:13 +00:00
|
|
|
RUN go generate ./...
|
2022-08-23 07:42:25 +00:00
|
|
|
|
2023-05-15 07:52:56 +00:00
|
|
|
FROM build-base AS build-windows-amd64
|
2024-08-14 21:24:17 +00:00
|
|
|
ENV GOOS=windows GOARCH=amd64
|
2024-11-06 14:15:25 +00:00
|
|
|
RUN go build -o "tmp/$(BINARY_NAME).exe"
|
|
|
|
RUN cd tmp && zip -q "../binaries/$(BINARY_NAME)_$$(cat ../internal/core/VERSION)_windows_amd64.zip" "$(BINARY_NAME).exe" mediamtx.yml LICENSE
|
2022-08-23 07:42:25 +00:00
|
|
|
|
2023-05-15 07:52:56 +00:00
|
|
|
FROM build-base AS build-linux-amd64
|
2024-08-14 21:24:17 +00:00
|
|
|
ENV GOOS=linux GOARCH=amd64
|
2024-11-06 14:15:25 +00:00
|
|
|
RUN go build -o "tmp/$(BINARY_NAME)"
|
|
|
|
RUN tar -C tmp -czf "binaries/$(BINARY_NAME)_$$(cat internal/core/VERSION)_linux_amd64.tar.gz" --owner=0 --group=0 "$(BINARY_NAME)" mediamtx.yml LICENSE
|
2022-08-23 07:42:25 +00:00
|
|
|
|
2023-05-15 07:52:56 +00:00
|
|
|
FROM build-base AS build-darwin-amd64
|
2024-08-14 21:24:17 +00:00
|
|
|
ENV GOOS=darwin GOARCH=amd64
|
2024-11-06 14:15:25 +00:00
|
|
|
RUN go build -o "tmp/$(BINARY_NAME)"
|
|
|
|
RUN tar -C tmp -czf "binaries/$(BINARY_NAME)_$$(cat internal/core/VERSION)_darwin_amd64.tar.gz" --owner=0 --group=0 "$(BINARY_NAME)" mediamtx.yml LICENSE
|
2022-08-23 07:42:25 +00:00
|
|
|
|
2023-05-15 07:52:56 +00:00
|
|
|
FROM build-base AS build-darwin-arm64
|
2024-08-14 21:24:17 +00:00
|
|
|
ENV GOOS=darwin GOARCH=arm64
|
2024-11-06 14:15:25 +00:00
|
|
|
RUN go build -o "tmp/$(BINARY_NAME)"
|
|
|
|
RUN tar -C tmp -czf "binaries/$(BINARY_NAME)_$$(cat internal/core/VERSION)_darwin_arm64.tar.gz" --owner=0 --group=0 "$(BINARY_NAME)" mediamtx.yml LICENSE
|
2023-05-14 13:56:51 +00:00
|
|
|
|
2023-05-15 07:52:56 +00:00
|
|
|
FROM build-base AS build-linux-armv6
|
2024-08-14 21:24:17 +00:00
|
|
|
ENV GOOS=linux GOARCH=arm GOARM=6
|
2024-11-06 14:15:25 +00:00
|
|
|
RUN go build -o "tmp/$(BINARY_NAME)"
|
|
|
|
RUN tar -C tmp -czf "binaries/$(BINARY_NAME)_$$(cat internal/core/VERSION)_linux_armv6.tar.gz" --owner=0 --group=0 "$(BINARY_NAME)" mediamtx.yml LICENSE
|
2022-08-23 07:42:25 +00:00
|
|
|
|
2023-05-15 07:52:56 +00:00
|
|
|
FROM build-base AS build-linux-armv7
|
2024-08-14 21:24:17 +00:00
|
|
|
ENV GOOS=linux GOARCH=arm GOARM=7
|
2024-11-06 14:15:25 +00:00
|
|
|
RUN go build -o "tmp/$(BINARY_NAME)"
|
|
|
|
RUN tar -C tmp -czf "binaries/$(BINARY_NAME)_$$(cat internal/core/VERSION)_linux_armv7.tar.gz" --owner=0 --group=0 "$(BINARY_NAME)" mediamtx.yml LICENSE
|
2022-08-23 07:42:25 +00:00
|
|
|
|
2023-05-15 07:52:56 +00:00
|
|
|
FROM build-base AS build-linux-arm64
|
2024-08-14 21:24:17 +00:00
|
|
|
ENV GOOS=linux GOARCH=arm64
|
2024-11-06 14:15:25 +00:00
|
|
|
RUN go build -o "tmp/$(BINARY_NAME)"
|
|
|
|
RUN tar -C tmp -czf "binaries/$(BINARY_NAME)_$$(cat internal/core/VERSION)_linux_arm64v8.tar.gz" --owner=0 --group=0 "$(BINARY_NAME)" mediamtx.yml LICENSE
|
2023-05-15 07:52:56 +00:00
|
|
|
|
|
|
|
FROM $(BASE_IMAGE)
|
|
|
|
COPY --from=build-windows-amd64 /s/binaries /s/binaries
|
|
|
|
COPY --from=build-linux-amd64 /s/binaries /s/binaries
|
|
|
|
COPY --from=build-darwin-amd64 /s/binaries /s/binaries
|
|
|
|
COPY --from=build-darwin-arm64 /s/binaries /s/binaries
|
|
|
|
COPY --from=build-linux-armv6 /s/binaries /s/binaries
|
|
|
|
COPY --from=build-linux-armv7 /s/binaries /s/binaries
|
|
|
|
COPY --from=build-linux-arm64 /s/binaries /s/binaries
|
2022-08-23 07:42:25 +00:00
|
|
|
endef
|
2022-09-17 18:15:23 +00:00
|
|
|
export DOCKERFILE_BINARIES
|
2022-08-23 07:42:25 +00:00
|
|
|
|
2022-09-17 18:15:23 +00:00
|
|
|
binaries:
|
2023-06-07 10:26:08 +00:00
|
|
|
echo "$$DOCKERFILE_BINARIES" | DOCKER_BUILDKIT=1 docker build . -f - \
|
|
|
|
-t temp
|
2024-11-06 14:15:25 +00:00
|
|
|
docker run --rm -v "$(PWD):/out" \
|
2022-09-17 18:15:23 +00:00
|
|
|
temp sh -c "rm -rf /out/binaries && cp -r /s/binaries /out/"
|