Skip to content

Commit de366ce

Browse files
committed
docker build
1 parent f8326bf commit de366ce

File tree

4 files changed

+173
-0
lines changed

4 files changed

+173
-0
lines changed

.dockerignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
build/
2+
autom4te.cache/
3+
*.o
4+
*.a
5+
*.so
6+
*.log
7+
*.tmp
8+
*.swp
9+
*~
10+
.vscode/
11+
.idea/
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "*"
9+
workflow_dispatch:
10+
11+
jobs:
12+
push:
13+
runs-on: ubuntu-24.04
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Free Disk Space Before Build
22+
run: |
23+
echo "Disk space before cleanup:"
24+
df -h
25+
sudo rm -rf /usr/local/.ghcup
26+
sudo rm -rf /opt/hostedtoolcache/CodeQL
27+
sudo rm -rf /usr/local/lib/android/sdk/ndk
28+
sudo rm -rf /usr/share/dotnet
29+
sudo rm -rf /opt/ghc
30+
sudo rm -rf /usr/local/share/boost
31+
sudo apt-get clean
32+
echo "Disk space after cleanup:"
33+
df -h
34+
35+
- name: Prepare tag
36+
id: prepare_tag
37+
run: |
38+
IMAGE_ID=jambonz/upload-recordings
39+
40+
# Strip git ref prefix from version
41+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
42+
43+
# Save original tag (with "v" prefix if it exists) in TAG
44+
TAG=$VERSION
45+
46+
# Strip "v" prefix from VERSION if it exists
47+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
48+
49+
# Use Docker `latest` tag convention if on main branch
50+
[ "$VERSION" == "main" ] && VERSION=latest
51+
52+
echo IMAGE_ID=$IMAGE_ID
53+
echo VERSION=$VERSION
54+
echo TAG=$TAG
55+
56+
echo "image_id=$IMAGE_ID" >> $GITHUB_OUTPUT
57+
echo "version=$VERSION" >> $GITHUB_OUTPUT
58+
echo "tag=$TAG" >> $GITHUB_OUTPUT
59+
60+
- name: Login to Docker Hub
61+
uses: docker/login-action@v3
62+
with:
63+
username: ${{ secrets.DOCKERHUB_USERNAME }}
64+
password: ${{ secrets.DOCKERHUB_TOKEN }}
65+
66+
- name: Set up Docker Buildx
67+
uses: docker/setup-buildx-action@v3
68+
with:
69+
version: "lab:latest"
70+
driver: cloud
71+
endpoint: "drachtio/freeswitch-builder"
72+
73+
- name: Build and push multi-arch image
74+
uses: docker/build-push-action@v5
75+
with:
76+
context: .
77+
platforms: linux/amd64,linux/arm64
78+
tags: ${{ steps.prepare_tag.outputs.image_id }}:${{ steps.prepare_tag.outputs.version }}
79+
build-args: |
80+
BUILD_CPUS=16
81+
push: true
82+
no-cache: true

Dockerfile

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
FROM debian:bookworm-slim
2+
3+
ARG BUILD_CPUS=4
4+
5+
RUN apt-get update \
6+
&& apt-get -y --quiet --force-yes upgrade \
7+
&& apt-get install -y --no-install-recommends ca-certificates gcc g++ make build-essential \
8+
cmake git autoconf automake pkg-config curl \
9+
libcjson-dev libmp3lame-dev libmysqlcppconn-dev libspdlog-dev libfmt-dev \
10+
libssl-dev libcurl4-openssl-dev libgoogle-perftools-dev libboost-all-dev \
11+
libev-dev
12+
13+
# Build libwebsockets v4.3.3 with libev support
14+
COPY ops-ws.c.patch /tmp/ops-ws.c.patch
15+
RUN cd /usr/local/src \
16+
&& git clone https://github.com/warmcat/libwebsockets.git -b v4.3.3 --depth 1 \
17+
&& cd libwebsockets/lib/roles/ws \
18+
&& patch ops-ws.c < /tmp/ops-ws.c.patch \
19+
&& cd /usr/local/src/libwebsockets \
20+
&& mkdir -p build && cd build \
21+
&& cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLWS_WITH_NETLINK=OFF -DLWS_WITH_LIBEV=1 \
22+
&& make -j${BUILD_CPUS} \
23+
&& make install \
24+
&& rm -rf /usr/local/src/libwebsockets
25+
26+
# Build AWS SDK C++ v1.11.500
27+
RUN cd /usr/local/src \
28+
&& git clone https://github.com/aws/aws-sdk-cpp -b 1.11.500 --depth 1 \
29+
&& cd aws-sdk-cpp \
30+
&& git submodule update --init --recursive \
31+
&& mkdir -p build && cd build \
32+
&& cmake .. -DBUILD_ONLY="s3;core;s3-crt;monitoring" \
33+
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
34+
-DBUILD_SHARED_LIBS=ON \
35+
-DENABLE_TESTING=OFF \
36+
-DAUTORUN_UNIT_TESTS=OFF \
37+
-DCMAKE_CXX_FLAGS="-Wno-unused-parameter -Wno-error=nonnull -Wno-error=deprecated-declarations -Wno-error=uninitialized -Wno-error=maybe-uninitialized -Wno-error=array-bounds" \
38+
&& make -j${BUILD_CPUS} \
39+
&& make install \
40+
&& find /usr/local/src/aws-sdk-cpp/ -type f -name "*.pc" -exec cp -t /usr/local/lib/pkgconfig/ {} + \
41+
&& rm -rf /usr/local/src/aws-sdk-cpp
42+
43+
COPY . /usr/local/src/upload-recordings
44+
45+
RUN cd /usr/local/src/upload-recordings \
46+
&& export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH \
47+
&& autoreconf -fi \
48+
&& mkdir -p build && cd build \
49+
&& ../configure --enable-tcmalloc=yes CXXFLAGS='-g -O2' \
50+
&& make -j${BUILD_CPUS} \
51+
&& make install \
52+
&& apt-get purge -y --quiet --auto-remove gcc g++ make cmake build-essential git autoconf automake pkg-config \
53+
&& rm -rf /var/lib/apt/* \
54+
&& rm -rf /var/lib/dpkg/* \
55+
&& rm -rf /var/lib/cache/* \
56+
&& rm -Rf /var/log/* \
57+
&& rm -Rf /var/lib/apt/lists/* \
58+
&& rm -Rf /usr/local/src/upload-recordings
59+
60+
RUN ldconfig
61+
62+
RUN mkdir -p /tmp/uploads
63+
64+
EXPOSE 3000
65+
66+
ENTRYPOINT ["upload_recordings"]
67+
CMD ["--port", "3000"]

ops-ws.c.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--- ops-ws.c 2024-07-19 17:00:55
2+
+++ ops-ws.c.new 2024-07-19 17:02:20
3+
@@ -1230,7 +1230,9 @@
4+
* Something has gone wrong, we are spinning...
5+
* let's bail on this connection
6+
*/
7+
- return LWS_HPI_RET_PLEASE_CLOSE_ME;
8+
+ //return LWS_HPI_RET_PLEASE_CLOSE_ME;
9+
+ //DH: this can happen with bidirectional audio
10+
+ return LWS_HPI_RET_HANDLED;
11+
}
12+
13+
if (buffered && /* were draining, now nothing left */

0 commit comments

Comments
 (0)