From a73d2ca72f4157bbd9c7b67ad92c509d0fb1ce0f Mon Sep 17 00:00:00 2001 From: Brian West Date: Fri, 3 Mar 2017 18:25:07 -0600 Subject: [PATCH] FS-10090: [Build-System] Add Docker files for master and release #resolve --- docker/README | 9 ++++++ docker/master/Dockerfile | 48 +++++++++++++++++++++++++++++ docker/master/docker-entrypoint.sh | 27 ++++++++++++++++ docker/release/Dockerfile | 48 +++++++++++++++++++++++++++++ docker/release/docker-entrypoint.sh | 27 ++++++++++++++++ 5 files changed, 159 insertions(+) create mode 100644 docker/README create mode 100644 docker/master/Dockerfile create mode 100755 docker/master/docker-entrypoint.sh create mode 100644 docker/release/Dockerfile create mode 100755 docker/release/docker-entrypoint.sh diff --git a/docker/README b/docker/README new file mode 100644 index 0000000000..564d700dbc --- /dev/null +++ b/docker/README @@ -0,0 +1,9 @@ +This is not OSHA approved, It may when used incorrectly cause workplace violence. + +If you wish to help improve these please submit a pull request at: + +https://freeswitch.org/jira + +Thanks, +/b + diff --git a/docker/master/Dockerfile b/docker/master/Dockerfile new file mode 100644 index 0000000000..f9191bac41 --- /dev/null +++ b/docker/master/Dockerfile @@ -0,0 +1,48 @@ +# vim:set ft=dockerfile: +FROM debian:jessie + +# Source Dockerfile: +# https://github.com/docker-library/postgres/blob/master/9.4/Dockerfile + +# explicitly set user/group IDs +RUN groupadd -r freeswitch --gid=999 && useradd -r -g freeswitch --uid=999 freeswitch + +# grab gosu for easy step-down from root +RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 +RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates wget && rm -rf /var/lib/apt/lists/* \ + && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture)" \ + && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture).asc" \ + && gpg --verify /usr/local/bin/gosu.asc \ + && rm /usr/local/bin/gosu.asc \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove ca-certificates wget + +# make the "en_US.UTF-8" locale so freeswitch will be utf-8 enabled by default +RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ + && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 +ENV LANG en_US.utf8 + +# https://files.freeswitch.org/repo/deb/freeswitch-1.*/dists/jessie/main/binary-amd64/Packages + +ENV FS_MAJOR debian-unstable + +RUN sed -i "s/jessie main/jessie main contrib non-free/" /etc/apt/sources.list + +# https://freeswitch.org/confluence/display/FREESWITCH/Debian+8+Jessie#Debian8Jessie-InstallingfromDebianpackages + +RUN apt-get update && apt-get install -y curl \ + && curl https://files.freeswitch.org/repo/deb/debian/freeswitch_archive_g0.pub | apt-key add - \ + && echo "deb http://files.freeswitch.org/repo/deb/$FS_MAJOR/ jessie main" > /etc/apt/sources.list.d/freeswitch.list \ + && apt-get purge -y --auto-remove curl + +RUN apt-get update && apt-get install -y freeswitch-all \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + +COPY docker-entrypoint.sh / +# Add anything else here + +## + +ENTRYPOINT ["/docker-entrypoint.sh"] + +CMD ["freeswitch"] diff --git a/docker/master/docker-entrypoint.sh b/docker/master/docker-entrypoint.sh new file mode 100755 index 0000000000..8b645a2b09 --- /dev/null +++ b/docker/master/docker-entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +set -e + +# Source docker-entrypoint.sh: +# https://github.com/docker-library/postgres/blob/master/9.4/docker-entrypoint.sh +# https://github.com/kovalyshyn/docker-freeswitch/blob/vanilla/docker-entrypoint.sh + +if [ "$1" = 'freeswitch' ]; then + + if [ ! -f "/etc/freeswitch/freeswitch.xml" ]; then + mkdir -p /etc/freeswitch + cp -varf /usr/share/freeswitch/conf/vanilla/* /etc/freeswitch/ + fi + + chown -R freeswitch:freeswitch /etc/freeswitch + chown -R freeswitch:freeswitch /var/{run,lib}/freeswitch + + if [ -d /docker-entrypoint.d ]; then + for f in /docker-entrypoint.d/*.sh; do + [ -f "$f" ] && . "$f" + done + fi + + exec gosu freeswitch /usr/bin/freeswitch -u freeswitch -g freeswitch -nonat -c +fi + +exec "$@" diff --git a/docker/release/Dockerfile b/docker/release/Dockerfile new file mode 100644 index 0000000000..8367946ae6 --- /dev/null +++ b/docker/release/Dockerfile @@ -0,0 +1,48 @@ +# vim:set ft=dockerfile: +FROM debian:jessie + +# Source Dockerfile: +# https://github.com/docker-library/postgres/blob/master/9.4/Dockerfile + +# explicitly set user/group IDs +RUN groupadd -r freeswitch --gid=999 && useradd -r -g freeswitch --uid=999 freeswitch + +# grab gosu for easy step-down from root +RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 +RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates wget && rm -rf /var/lib/apt/lists/* \ + && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture)" \ + && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture).asc" \ + && gpg --verify /usr/local/bin/gosu.asc \ + && rm /usr/local/bin/gosu.asc \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove ca-certificates wget + +# make the "en_US.UTF-8" locale so freeswitch will be utf-8 enabled by default +RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ + && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 +ENV LANG en_US.utf8 + +# https://files.freeswitch.org/repo/deb/freeswitch-1.*/dists/jessie/main/binary-amd64/Packages + +ENV FS_MAJOR 1.6 + +RUN sed -i "s/jessie main/jessie main contrib non-free/" /etc/apt/sources.list + +# https://freeswitch.org/confluence/display/FREESWITCH/Debian+8+Jessie#Debian8Jessie-InstallingfromDebianpackages + +RUN apt-get update && apt-get install -y curl \ + && curl https://files.freeswitch.org/repo/deb/debian/freeswitch_archive_g0.pub | apt-key add - \ + && echo "deb http://files.freeswitch.org/repo/deb/freeswitch-$FS_MAJOR/ jessie main" > /etc/apt/sources.list.d/freeswitch.list \ + && apt-get purge -y --auto-remove curl + +RUN apt-get update && apt-get install -y freeswitch-all \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + +COPY docker-entrypoint.sh / +# Add anything else here + +## + +ENTRYPOINT ["/docker-entrypoint.sh"] + +CMD ["freeswitch"] diff --git a/docker/release/docker-entrypoint.sh b/docker/release/docker-entrypoint.sh new file mode 100755 index 0000000000..8b645a2b09 --- /dev/null +++ b/docker/release/docker-entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +set -e + +# Source docker-entrypoint.sh: +# https://github.com/docker-library/postgres/blob/master/9.4/docker-entrypoint.sh +# https://github.com/kovalyshyn/docker-freeswitch/blob/vanilla/docker-entrypoint.sh + +if [ "$1" = 'freeswitch' ]; then + + if [ ! -f "/etc/freeswitch/freeswitch.xml" ]; then + mkdir -p /etc/freeswitch + cp -varf /usr/share/freeswitch/conf/vanilla/* /etc/freeswitch/ + fi + + chown -R freeswitch:freeswitch /etc/freeswitch + chown -R freeswitch:freeswitch /var/{run,lib}/freeswitch + + if [ -d /docker-entrypoint.d ]; then + for f in /docker-entrypoint.d/*.sh; do + [ -f "$f" ] && . "$f" + done + fi + + exec gosu freeswitch /usr/bin/freeswitch -u freeswitch -g freeswitch -nonat -c +fi + +exec "$@"