From bde7690e374022231b0b7be3d4a6993b2b6b5428 Mon Sep 17 00:00:00 2001 From: LarryLaffer-dev Date: Mon, 24 Mar 2025 17:31:58 +0100 Subject: [PATCH 1/2] Docker Build --- Bump.sh | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 22 ++++++++ VERSION | 1 + build | 7 +++ build-deb.sh | 14 +++++ 5 files changed, 193 insertions(+) create mode 100755 Bump.sh create mode 100644 Dockerfile create mode 100644 VERSION create mode 100755 build create mode 100755 build-deb.sh diff --git a/Bump.sh b/Bump.sh new file mode 100755 index 00000000000..9a966fd722d --- /dev/null +++ b/Bump.sh @@ -0,0 +1,149 @@ +#!/usr/bin/env sh + +VERSION_FILE=$(head -1 < VERSION) +VERSION_NUMBER=$(echo "$VERSION_FILE" | cut -d'-' -f1 | cut -d'+' -f1) +PRE_RELEASE=$(echo "$VERSION_FILE" | cut -d'-' -f2 | cut -d'+' -f1) +BUILD=$(echo "$VERSION_FILE" |cut -d'-' -f2 | cut -d'+' -f2) +if [ "$PRE_RELEASE" = "$VERSION_NUMBER" ]; then + PRE_RELEASE="" +fi +if [ "$BUILD" = "$VERSION_NUMBER" ] || [ "$BUILD" = "$PRE_RELEASE" ]; then + BUILD="" +fi + +MAJOR=$(echo "$VERSION_NUMBER" | cut -d'.' -f1) +MINOR=$(echo "$VERSION_NUMBER" | cut -d'.' -f2) +PATCH=$(echo "$VERSION_NUMBER" | cut -d'.' -f3) +PRE_RELEASE_IDENTIFIER=$(echo "$PRE_RELEASE." | cut -d'.' -f2) + +_usage() { + echo "Usage: ./$(basename $0) (major|minor|patch|rc|release)" + echo "" + echo "Current Version" + echo "---------------" + echo "" + echo "MAJOR : $MAJOR" + echo "MINOR : $MINOR" + echo "PATCH : $PATCH" + echo "PRE_RELEASE : $PRE_RELEASE" + echo "BUILD : $BUILD" + echo "" + exit 1 +} + +_build_version() { + if [ -z "$MAJOR" ]; then + MAJOR=0 + fi + if [ -z "$MINOR" ]; then + MINOR=0 + fi + if [ -z "$PATCH" ]; then + PATCH=0 + fi + VERSION_NUMBER="${MAJOR}.${MINOR}.${PATCH}" + if [ -n "$PRE_RELEASE" ]; then + PRE_RELEASE="-$PRE_RELEASE" + fi + if [ -n "$BUILD" ]; then + BUILD="+$BUILD" + fi + echo "${VERSION_NUMBER}${PRE_RELEASE}${BUILD}" > VERSION +} + +_bump_major() { + if [ -n "$MAJOR" ]; then + MAJOR=$((MAJOR+1)) + MINOR=0 + PATCH=0 + fi + git stash --include-untracked + _build_version + VERSION_GIT=$(head -1 < VERSION) + git add VERSION + git commit -m "Bumping new major ${VERSION_GIT}" + git push origin + git stash pop +} + +_bump_minor() { + if [ -n "$MINOR" ]; then + MINOR=$((MINOR+1)) + PATCH=0 + fi + git stash --include-untracked + _build_version + VERSION_GIT=$(head -1 < VERSION) + git add VERSION + git commit -m "Bumping new minor ${VERSION_GIT}" + git push origin + git stash pop +} + +_bump_patch() { + if [ -n "$PATCH" ]; then + PATCH=$((PATCH+1)) + fi + git stash --include-untracked + _build_version + VERSION_GIT=$(head -1 < VERSION) + git add VERSION + git commit -m "Bumping new patch ${VERSION_GIT}" + git push origin + git stash pop +} + +_bump_rc() { + if [ -z "$PRE_RELEASE_IDENTIFIER" ]; then + PRE_RELEASE_IDENTIFIER=1 + else + PRE_RELEASE_IDENTIFIER=$((PRE_RELEASE_IDENTIFIER+1)) + fi + PRE_RELEASE="rc.$PRE_RELEASE_IDENTIFIER" + git stash --include-untracked + _build_version + VERSION_GIT=$(head -1 < VERSION) + git add VERSION + git commit -m "Bumping new release candiate ${VERSION_GIT}" + git tag -am "Tagging new release candiate ${VERSION_GIT}" "${VERSION_GIT}" + git push origin "${VERSION_GIT}" + git push origin + git stash pop +} + +_bump_release() { + PRE_RELEASE="" + BUILD="" + git stash --include-untracked + _build_version + VERSION_GIT=$(head -1 < VERSION) + git add VERSION + git commit -m "Bumping new release ${VERSION_GIT}" + git push origin + git stash pop +} + +if [ $# != 1 ]; then + _usage +fi + +case "$1" in + major) + _bump_major + ;; + minor) + _bump_minor + ;; + patch) + _bump_patch + ;; + rc) + _bump_rc + ;; + release) + _bump_release + ;; + *) + _usage + ;; +esac diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000000..d387a5f9e23 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM debian:bullseye AS builder +RUN export DEBIAN_FRONTEND=noninteractive +RUN echo 'deb http://deb.debian.org/debian bullseye-backports main' > /etc/apt/sources.list.d/backports.list +RUN apt-get update && apt-get install -y dpkg-dev dnsutils wget software-properties-common net-tools curl lsb-release debhelper sofia-sip-bin flex bison devscripts default-libmysqlclient-dev docbook-xml erlang-dev libconfuse-dev libdb-dev libev-dev libevent-dev libexpat1-dev libgeoip-dev libhiredis-dev libjansson-dev libjson-c-dev libldap2-dev liblua5.1-0-dev libmemcached-dev libmono-2.0-dev libncurses5-dev libpcre3-dev libperl-dev libpq-dev librabbitmq-dev libradcli-dev libreadline-dev libsasl2-dev libsctp-dev libsnmp-dev libsqlite3-dev libsystemd-dev libunistring-dev libxml2-dev pkg-config python python-dev unixodbc-dev uuid-dev xsltproc zlib1g-dev libbson-dev libmaxminddb-dev libmnl-dev libmongoc-dev libphonenumber-dev python3-dev ruby-dev libwolfssl-dev libssl-dev musl-dev musl-tools libcurl4-gnutls-dev libmicrohttpd-dev librdkafka-dev git-core libfreediameter-dev libjwt-dev +COPY . /tmp/build/opensips/ +COPY build-deb.sh /usr/sbin/build-deb.sh +RUN /usr/sbin/build-deb.sh + +FROM debian:bullseye +COPY --from=builder /tmp/deb/ /tmp/debs/ +RUN export DEBIAN_FRONTEND=noninteractive && \ +apt-get update && \ +dpkg -i /tmp/debs/*.deb || true && \ +apt-get update && apt-get -f -y install && \ +apt-get -y install gnupg2 ca-certificates iproute2 mariadb-client gettext-base gdb && \ +apt-key adv --fetch-keys https://apt.opensips.org/pubkey.gpg && \ +echo "deb https://apt.opensips.org bullseye cli-nightly" >/etc/apt/sources.list.d/opensips-cli.list && \ +apt-get -y update -qq && apt-get -y install opensips-cli && \ +apt-get autoremove --purge -y && \ +apt-get clean && \ +rm -rf /var/lib/apt/lists/* +ENTRYPOINT ["/usr/sbin/opensips", "-F"] diff --git a/VERSION b/VERSION new file mode 100644 index 00000000000..8acdd82b765 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.0.1 diff --git a/build b/build new file mode 100755 index 00000000000..e027ef8cc50 --- /dev/null +++ b/build @@ -0,0 +1,7 @@ +#!/bin/bash +VERSION_GIT=$(head -1 < VERSION) +echo "Building version $VERSION_GIT" +docker build -t registry.volte.io/opensips:$VERSION_GIT -f Dockerfile . +docker push registry.volte.io/opensips:$VERSION_GIT +docker tag registry.volte.io/opensips:$VERSION_GIT registry.volte.io/opensips:latest +docker push registry.volte.io/opensips:latest diff --git a/build-deb.sh b/build-deb.sh new file mode 100755 index 00000000000..301caf4254d --- /dev/null +++ b/build-deb.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +cd /tmp/build/opensips +git submodule update --init +mkdir /tmp/deb/ +make deb-orig-tar +mv ../opensips_3.6.0.orig.tar.gz ../opensips_3.6.0-dev.orig.tar.gz +make deb +cp ../*.deb /tmp/deb +cd /tmp/deb +dpkg-scanpackages . /dev/null > Packages +dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz From a22ac9a87455f41106ee004e2096c1f69f7bbb87 Mon Sep 17 00:00:00 2001 From: Carsten Date: Wed, 28 May 2025 11:22:44 +0200 Subject: [PATCH 2/2] Update build script to 3.7.x --- build-deb.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-deb.sh b/build-deb.sh index 301caf4254d..85ddffd59d3 100755 --- a/build-deb.sh +++ b/build-deb.sh @@ -6,7 +6,7 @@ cd /tmp/build/opensips git submodule update --init mkdir /tmp/deb/ make deb-orig-tar -mv ../opensips_3.6.0.orig.tar.gz ../opensips_3.6.0-dev.orig.tar.gz +mv ../opensips_3.7.0.orig.tar.gz ../opensips_3.7.0-dev.orig.tar.gz make deb cp ../*.deb /tmp/deb cd /tmp/deb