From 56d1cfd2254328a97e2d91823be47a5040d07dc2 Mon Sep 17 00:00:00 2001 From: Infactum Date: Wed, 21 Nov 2018 22:35:36 +0500 Subject: [PATCH] Feature multi distro (#4) --- README.md | 6 ++- appveyor.yml | 38 +++++++++------- buildenv/{Dockerfile => Dockerfile.bionic} | 0 buildenv/Dockerfile.centos7 | 53 ++++++++++++++++++++++ 4 files changed, 79 insertions(+), 18 deletions(-) rename buildenv/{Dockerfile => Dockerfile.bionic} (100%) create mode 100644 buildenv/Dockerfile.centos7 diff --git a/README.md b/README.md index 0225522..b0a374d 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,10 @@ Your SIP PBX should be comaptible with `L16@48000` or `OPUS@48000` voice codec. ## Usage -1. [Download](https://ci.appveyor.com/api/projects/Infactum/tg2sip/artifacts/tg2sip.zip?branch=master) prebuild version from CI or compile it yourself. -Prebuild binaries have been tested in Ubuntu 18.04 Bionic and require `libopus0` package installed. +1. Download prebuild versions for supported OS from CI or compile it yourself. +[Ubuntu 18.04 Bionic](https://ci.appveyor.com/api/projects/Infactum/tg2sip/artifacts/tg2sip_bionic.zip?branch=master&job=Environment%3A%20target_name%3DUbuntu%20Bionic%2C%20docker_tag%3Dbionic) +[CentOS 7](https://ci.appveyor.com/api/projects/Infactum/tg2sip/artifacts/tg2sip_centos7.zip?branch=master&job=Environment%3A%20target_name%3DUbuntu%20Bionic%2C%20docker_tag%3Dcentos7) +Prebuild binaries requires OPUS libraries (`libopus0` for Ubuntu, `opus` for CentOS, etc). 2. Obtain `api_id` and `api_hash` tokens from [this](https://my.telegram.org) page and put them in `settings.ini` file. 3. Login into telegram with `gen_db` app 4. Set SIP server settings in `settings.ini` diff --git a/appveyor.yml b/appveyor.yml index df3122b..2b99921 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,32 +1,41 @@ version: 1.0.0+{build} image: - - Ubuntu + - Previous Ubuntu + +services: + - docker configuration: Release platform: x64 environment: - DOCKER_LOGIN: infactum - DOCKER_PASSWORD: - secure: wWPsUiEtw8rfnjX2/Y3/AA== - DOCKER_IMAGE: infactum/tg2sip-builder + global: + docker_login: infactum + docker_password: + secure: wWPsUiEtw8rfnjX2/Y3/AA== + docker_image: infactum/tg2sip-builder matrix: - - TARGET_PLATFORM: x64 + - target_name: Ubuntu Bionic + docker_tag: bionic + + - target_name: CentOS 7 + docker_tag: centos7 init: - sh: | - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD - docker pull $DOCKER_IMAGE -install: - - sh: docker build buildenv/ --cache-from $DOCKER_IMAGE -t $DOCKER_IMAGE:latest + docker login -u "$docker_login" -p "$docker_password" + docker pull "$docker_image":"$docker_tag" + +install: + - sh: docker build buildenv/ -f buildenv/Dockerfile."$docker_tag" --cache-from "$docker_image":"$docker_tag" -t "$docker_image":"$docker_tag" build_script: - sh: >- mkdir build; - docker run --rm -v $(pwd):/src $DOCKER_IMAGE /bin/bash -c " + docker run --rm -v "$(pwd)":/src "$docker_image" /bin/bash -c " mkdir build && cd build; cmake -DCMAKE_BUILD_TYPE=Release /src; cmake --build .; @@ -37,8 +46,5 @@ build_script: 7z a tg2sip.zip ./build/tg2sip ./build/gen_db ./settings.ini; after_build: - - sh: docker push $DOCKER_IMAGE - -artifacts: - - path: tg2sip.zip - name: TG2SIP Ubuntu Bionic \ No newline at end of file + - sh: docker push "$docker_image":"$docker_tag" + - sh: appveyor PushArtifact tg2sip.zip -FileName tg2sip_"$docker_tag".zip -DeploymentName "TG2SIP $target_name" \ No newline at end of file diff --git a/buildenv/Dockerfile b/buildenv/Dockerfile.bionic similarity index 100% rename from buildenv/Dockerfile rename to buildenv/Dockerfile.bionic diff --git a/buildenv/Dockerfile.centos7 b/buildenv/Dockerfile.centos7 new file mode 100644 index 0000000..3502758 --- /dev/null +++ b/buildenv/Dockerfile.centos7 @@ -0,0 +1,53 @@ +FROM centos:7 as builder + +# https://www.softwarecollections.org/en/scls/rhscl/devtoolset-7/ +RUN yum -y install centos-release-scl yum-utils \ + && yum-config-manager --enable rhel-server-rhscl-7-rpms \ + && yum install -y devtoolset-7-gcc devtoolset-7-gcc-c++ + +RUN yum install -y \ + make \ + git wget \ + zlib-devel opus-devel openssl-devel gperf \ + pkgconfig ccache gperf unzip + +RUN wget https://cmake.org/files/v3.9/cmake-3.9.6-Linux-x86_64.sh \ + && sh cmake-3.9.6-Linux-x86_64.sh --prefix=/usr --exclude-subdir + +COPY tdlib_header.patch / +COPY tdlib_threadname.patch / + +RUN source /opt/rh/devtoolset-7/enable \ + && git clone https://github.com/tdlib/td.git \ + && cd td \ + && git reset --hard v1.2.0 \ + && git apply /tdlib_header.patch \ + && git apply /tdlib_threadname.patch \ + && mkdir build \ + && cd build \ + && cmake -DCMAKE_BUILD_TYPE=Release .. \ + && cmake --build . --target install \ + && cd / \ + && rm -rf td + +COPY config_site.h / + +RUN source /opt/rh/devtoolset-7/enable \ + && git clone https://github.com/Infactum/pjproject.git \ + && cd pjproject \ + && cp /config_site.h pjlib/include/pj \ + && ./configure --disable-sound CFLAGS="-O3 -DNDEBUG" \ + && make dep && make && make install \ + && cd / \ + && rm -rf pjproject + +RUN source /opt/rh/devtoolset-7/enable \ + && git clone -n https://github.com/gabime/spdlog.git \ + && cd spdlog \ + && git checkout tags/v0.17.0 \ + && mkdir build \ + && cd build \ + && cmake -DCMAKE_BUILD_TYPE=Release -DSPDLOG_BUILD_EXAMPLES=OFF -DSPDLOG_BUILD_TESTING=OFF .. \ + && cmake --build . --target install \ + && cd / \ + && rm -rf spdlog \ No newline at end of file