From 5ee913a3bf45195b121684f5c015a720e26c6984 Mon Sep 17 00:00:00 2001 From: Gemfield Date: Tue, 14 Jan 2020 19:36:36 +0800 Subject: [PATCH] Split Dockerfile to runtime and devel version, and also reduce the image size for runtime version --- build_docker_images.sh | 3 + .../Dockerfile.devel} | 7 ++- docker/ubuntu16.04/Dockerfile.runtime | 62 +++++++++++++++++++ docker/ubuntu18.04/Dockerfile.devel | 44 +++++++++++++ docker/ubuntu18.04/Dockerfile.runtime | 62 +++++++++++++++++++ 5 files changed, 176 insertions(+), 2 deletions(-) create mode 100644 build_docker_images.sh rename docker/{Dockerfile => ubuntu16.04/Dockerfile.devel} (82%) create mode 100644 docker/ubuntu16.04/Dockerfile.runtime create mode 100644 docker/ubuntu18.04/Dockerfile.devel create mode 100644 docker/ubuntu18.04/Dockerfile.runtime diff --git a/build_docker_images.sh b/build_docker_images.sh new file mode 100644 index 00000000..a642584f --- /dev/null +++ b/build_docker_images.sh @@ -0,0 +1,3 @@ +#!/bin/bash +docker build -t gemfield/zlmediakit:20.01-runtime-ubuntu18.04 -f docker/ubuntu18.04/Dockerfile.runtime . +#docker build -t gemfield/zlmediakit:20.01-devel-ubuntu18.04 -f docker/ubuntu18.04/Dockerfile.devel . diff --git a/docker/Dockerfile b/docker/ubuntu16.04/Dockerfile.devel similarity index 82% rename from docker/Dockerfile rename to docker/ubuntu16.04/Dockerfile.devel index d939ab14..650bd206 100644 --- a/docker/Dockerfile +++ b/docker/ubuntu16.04/Dockerfile.devel @@ -9,7 +9,9 @@ EXPOSE 443/tcp EXPOSE 10000/udp EXPOSE 10000/tcp -RUN apt-get update && apt-get install -y --no-install-recommends \ +RUN apt-get update && \ + DEBIAN_FRONTEND="noninteractive" \ + apt-get install -y --no-install-recommends \ build-essential \ cmake \ git \ @@ -22,6 +24,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libx264-dev \ libfaac-dev \ libmp4v2-dev && \ + apt autoremove -y && \ + apt clean -y && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /opt/media @@ -36,5 +40,4 @@ RUN cmake -DCMAKE_BUILD_TYPE=Release .. && \ make -j4 ENV PATH /opt/media/ZLMediaKit/release/linux/Release/:$PATH - CMD MediaServer diff --git a/docker/ubuntu16.04/Dockerfile.runtime b/docker/ubuntu16.04/Dockerfile.runtime new file mode 100644 index 00000000..4bd6382f --- /dev/null +++ b/docker/ubuntu16.04/Dockerfile.runtime @@ -0,0 +1,62 @@ +FROM ubuntu:16.04 AS build +#shell,rtmp,rtsp,rtsps,http,https,rtp +EXPOSE 9000/tcp +EXPOSE 1935/tcp +EXPOSE 554/tcp +EXPOSE 322/tcp +EXPOSE 80/tcp +EXPOSE 443/tcp +EXPOSE 10000/udp +EXPOSE 10000/tcp + +RUN apt-get update && \ + DEBIAN_FRONTEND="noninteractive" \ + apt-get install -y --no-install-recommends \ + build-essential \ + cmake \ + git \ + curl \ + vim \ + ca-certificates \ + tzdata \ + libssl-dev \ + libmysqlclient-dev \ + libx264-dev \ + libfaac-dev \ + libmp4v2-dev && \ + apt autoremove -y && \ + apt clean -y && \ + rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /opt/media + +WORKDIR /opt/media +RUN git clone --depth=1 https://github.com/xiongziliang/ZLMediaKit && \ + cd ZLMediaKit && git submodule update --init --recursive && \ + mkdir -p build release/linux/Release/ + +WORKDIR /opt/media/ZLMediaKit/build +RUN cmake -DCMAKE_BUILD_TYPE=Release .. && \ + make -j4 + +FROM ubuntu:16.04 +LABEL maintainer "Gemfield " + +RUN apt-get update && \ + DEBIAN_FRONTEND="noninteractive" \ + apt-get install -y --no-install-recommends \ + vim \ + ca-certificates \ + tzdata \ + libssl-dev \ + libx264-dev \ + libfaac-dev \ + libmp4v2-dev && \ + apt autoremove -y && \ + apt clean -y && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /opt/media/bin/ +COPY --from=build /opt/media/ZLMediaKit/release/linux/Release/MediaServer /opt/media/bin/MediaServer +ENV PATH /opt/media/bin:$PATH +CMD MediaServer \ No newline at end of file diff --git a/docker/ubuntu18.04/Dockerfile.devel b/docker/ubuntu18.04/Dockerfile.devel new file mode 100644 index 00000000..335c9a3f --- /dev/null +++ b/docker/ubuntu18.04/Dockerfile.devel @@ -0,0 +1,44 @@ +FROM ubuntu:18.04 +LABEL maintainer "Gemfield " +#shell,rtmp,rtsp,rtsps,http,https,rtp +EXPOSE 9000/tcp +EXPOSE 1935/tcp +EXPOSE 554/tcp +EXPOSE 322/tcp +EXPOSE 80/tcp +EXPOSE 443/tcp +EXPOSE 10000/udp +EXPOSE 10000/tcp + +RUN apt-get update && \ + DEBIAN_FRONTEND="noninteractive" \ + apt-get install -y --no-install-recommends \ + build-essential \ + cmake \ + git \ + curl \ + vim \ + ca-certificates \ + tzdata \ + libssl-dev \ + libmysqlclient-dev \ + libx264-dev \ + libfaac-dev \ + libmp4v2-dev && \ + apt autoremove -y && \ + apt clean -y && \ + rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /opt/media + +WORKDIR /opt/media +RUN git clone --depth=1 https://github.com/xiongziliang/ZLMediaKit && \ + cd ZLMediaKit && git submodule update --init --recursive && \ + mkdir -p build release/linux/Release/ + +WORKDIR /opt/media/ZLMediaKit/build +RUN cmake -DCMAKE_BUILD_TYPE=Release .. && \ + make -j4 + +ENV PATH /opt/media/ZLMediaKit/release/linux/Release:$PATH +CMD MediaServer \ No newline at end of file diff --git a/docker/ubuntu18.04/Dockerfile.runtime b/docker/ubuntu18.04/Dockerfile.runtime new file mode 100644 index 00000000..f10c2658 --- /dev/null +++ b/docker/ubuntu18.04/Dockerfile.runtime @@ -0,0 +1,62 @@ +FROM ubuntu:18.04 AS build +#shell,rtmp,rtsp,rtsps,http,https,rtp +EXPOSE 9000/tcp +EXPOSE 1935/tcp +EXPOSE 554/tcp +EXPOSE 322/tcp +EXPOSE 80/tcp +EXPOSE 443/tcp +EXPOSE 10000/udp +EXPOSE 10000/tcp + +RUN apt-get update && \ + DEBIAN_FRONTEND="noninteractive" \ + apt-get install -y --no-install-recommends \ + build-essential \ + cmake \ + git \ + curl \ + vim \ + ca-certificates \ + tzdata \ + libssl-dev \ + libmysqlclient-dev \ + libx264-dev \ + libfaac-dev \ + libmp4v2-dev && \ + apt autoremove -y && \ + apt clean -y && \ + rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /opt/media + +WORKDIR /opt/media +RUN git clone --depth=1 https://github.com/xiongziliang/ZLMediaKit && \ + cd ZLMediaKit && git submodule update --init --recursive && \ + mkdir -p build release/linux/Release/ + +WORKDIR /opt/media/ZLMediaKit/build +RUN cmake -DCMAKE_BUILD_TYPE=Release .. && \ + make -j4 + +FROM ubuntu:18.04 +LABEL maintainer "Gemfield " + +RUN apt-get update && \ + DEBIAN_FRONTEND="noninteractive" \ + apt-get install -y --no-install-recommends \ + vim \ + ca-certificates \ + tzdata \ + libssl-dev \ + libx264-dev \ + libfaac-dev \ + libmp4v2-dev && \ + apt autoremove -y && \ + apt clean -y && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /opt/media/bin/ +COPY --from=build /opt/media/ZLMediaKit/release/linux/Release/MediaServer /opt/media/bin/MediaServer +ENV PATH /opt/media/bin:$PATH +CMD MediaServer \ No newline at end of file