Skip to content

Commit

Permalink
feat: build one more production image with debug symbols included
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Apr 14, 2020
1 parent 6096341 commit 770b6a9
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Dockerfile-dev
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ FROM restreamio/gstreamer:latest-dev-with-source
FROM restreamio/gstreamer:latest-dev-dependencies

# And binaries built with debug symbols
COPY --from=0 /gstreamer-binaries /
COPY --from=0 /compiled-binaries /
1 change: 1 addition & 0 deletions Dockerfile-dev-with-source
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM restreamio/gstreamer:latest-dev-downloaded

ENV DEBUG=true
ENV OPTIMIZATIONS=false

# Compile binaries with debug symbols and keep source code
RUN ["/compile"]
33 changes: 3 additions & 30 deletions Dockerfile-prod
Original file line number Diff line number Diff line change
@@ -1,37 +1,10 @@
FROM restreamio/gstreamer:latest-dev-downloaded

ENV DEBUG=false
ENV OPTIMIZATIONS=true

RUN ["/compile"]

FROM ubuntu:20.04
FROM restreamio/gstreamer:latest-prod-base

RUN \
apt-get update && \
apt-get dist-upgrade -y && \
# This allows us to easily install what is necessary for GStreamer to work
apt-get install -y --no-install-recommends \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
gstreamer1.0-nice && \
# However, we don't need GStreamer itself and its plugins, since we've just built them from source
apt-get remove -y --purge \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
gstreamer1.0-nice \
libgstreamer-plugins-bad1.0-0 \
libgstreamer-plugins-base1.0-0 \
libgstreamer-plugins-good1.0-0 \
libgstreamer1.0-0 \
libusrsctp1 \
libnice10 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

COPY --from=0 /gstreamer-binaries /
COPY --from=0 /compiled-binaries /
29 changes: 29 additions & 0 deletions Dockerfile-prod-base
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM ubuntu:20.04

RUN \
apt-get update && \
apt-get dist-upgrade -y && \
# This allows us to easily install what is necessary for GStreamer to work
apt-get install -y --no-install-recommends \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
gstreamer1.0-nice && \
# However, we don't need GStreamer itself and its plugins, since we've just built them from source
apt-get remove -y --purge \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
gstreamer1.0-nice \
libgstreamer-plugins-bad1.0-0 \
libgstreamer-plugins-base1.0-0 \
libgstreamer-plugins-good1.0-0 \
libgstreamer1.0-0 \
libusrsctp1 \
libnice10 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
10 changes: 10 additions & 0 deletions Dockerfile-prod-dbg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM restreamio/gstreamer:latest-dev-downloaded

ENV DEBUG=true
ENV OPTIMIZATIONS=true

RUN ["/compile"]

FROM restreamio/gstreamer:latest-prod-base

COPY --from=0 /compiled-binaries /
6 changes: 5 additions & 1 deletion build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@ docker build -t restreamio/gstreamer:latest-dev-downloaded -f Dockerfile-dev-dow
docker build -t restreamio/gstreamer:latest-dev-with-source -f Dockerfile-dev-with-source .
# Build dev image with just binaries
docker build -t restreamio/gstreamer:latest-dev -f Dockerfile-dev .
# Build production image with just binaries and necessary dependencies
# Build base production image with necessary dependencies
docker build -t restreamio/gstreamer:latest-prod-base -f Dockerfile-prod-base .
# Build production image optimized binaries and no debug symbols (-O3 LTO)
docker build -t restreamio/gstreamer:latest-prod -f Dockerfile-prod .
# Build production image optimized binaries and debug symbols
docker build -t restreamio/gstreamer:latest-prod-dbg -f Dockerfile-prod-dbg .
15 changes: 10 additions & 5 deletions docker/build-gstreamer/compile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ for repo in gstreamer usrsctp libnice gst-plugins-base gst-plugins-bad gst-plugi
pushd $repo
# TODO: Hack: `-D gupnp=disabled` is for libnice, because libgupnp-igd causes memory leaks
if [[ $DEBUG == 'true' ]]; then
meson build -D prefix=/usr -D gupnp=disabled
# meson build -D prefix=/usr
if [[ $OPTIMIZATIONS == 'true' ]]; then
meson build -D prefix=/usr -D gupnp=disabled -D debug=true -D optimization=2
#meson build -D prefix=/usr
else
meson build -D prefix=/usr -D gupnp=disabled -D debug=true
#meson build -D prefix=/usr
fi
else
meson build -D prefix=/usr -D gupnp=disabled -D optimization=3 -D debug=false -D b_lto=true -D buildtype=release
# meson build -D prefix=/usr -D optimization=3 -D debug=false -D b_lto=true -D buildtype=release
meson build -D prefix=/usr -D gupnp=disabled -D debug=false -D optimization=3 -D b_lto=true -D buildtype=release
#meson build -D prefix=/usr -D optimization=3 -D debug=false -D b_lto=true -D buildtype=release
fi
# This is needed for other plugins to be built properly
ninja -C build install
# This is where we'll grab build artifacts from
DESTDIR=/gstreamer-binaries ninja -C build install
DESTDIR=/compiled-binaries ninja -C build install
popd
done

Expand Down
2 changes: 1 addition & 1 deletion push-all.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

# Make sure to always have fresh base image
docker push restreamio/gstreamer:latest-dev-with-source
docker push restreamio/gstreamer:latest-dev
docker push restreamio/gstreamer:latest-prod
docker push restreamio/gstreamer:latest-prod-dbg

0 comments on commit 770b6a9

Please sign in to comment.