Skip to content

Commit e0bcff4

Browse files
committed
test: Add a fully static build with A/V support.
1 parent 57d330c commit e0bcff4

File tree

3 files changed

+132
-0
lines changed

3 files changed

+132
-0
lines changed

Diff for: .github/workflows/ci.yml

+11
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,14 @@ jobs:
123123
- name: Print log
124124
run:
125125
cat /__w/toxic/toxic/infer-out/report.txt
126+
127+
docker-static:
128+
runs-on: ubuntu-latest
129+
steps:
130+
- name: Set up Docker Buildx
131+
uses: docker/setup-buildx-action@v2
132+
- name: Build docker image
133+
uses: docker/build-push-action@v4
134+
with:
135+
file: script/Dockerfile
136+
tags: toxchat/toxic

Diff for: script/Dockerfile

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
FROM alpine:3.19.0 AS build
2+
3+
RUN ["apk", "add", "--no-cache", \
4+
"autoconf", \
5+
"automake", \
6+
"brotli-static", \
7+
"c-ares-static", \
8+
"cmake", \
9+
"curl-dev", \
10+
"curl-static", \
11+
"diffutils", \
12+
"g++", \
13+
"gcc", \
14+
"git", \
15+
"libconfig-dev", \
16+
"libconfig-static", \
17+
"libidn2-static", \
18+
"libsodium-dev", \
19+
"libsodium-static", \
20+
"libtool", \
21+
"libunistring-static", \
22+
"libx11-dev", \
23+
"libx11-static", \
24+
"libxcb-static", \
25+
"linux-headers", \
26+
"make", \
27+
"ncurses-dev", \
28+
"ncurses-static", \
29+
"nghttp2-static", \
30+
"openssl-libs-static", \
31+
"pkgconfig", \
32+
"python3-dev", \
33+
"yasm", \
34+
"zlib-static"]
35+
36+
WORKDIR /work/portaudio
37+
RUN ["git", "clone", "--branch=v19.7.0", "--depth=1", "https://github.com/PortAudio/portaudio", "/work/portaudio"]
38+
RUN ["cmake", "-B_build", "-H.", "-DBUILD_SHARED_LIBS=OFF"]
39+
RUN cmake --build _build --target install -- "-j$(nproc)"
40+
41+
WORKDIR /work/openal-soft
42+
RUN ["git", "clone", "--branch=1.23.1", "--depth=1", "https://github.com/kcat/openal-soft", "/work/openal-soft"]
43+
RUN ["cmake", "-B_build", "-H.", "-DLIBTYPE=STATIC", "-DALSOFT_EXAMPLES=OFF", "-DALSOFT_UTILS=OFF", "-DALSOFT_DLOPEN=OFF"]
44+
RUN cmake --build _build --target install -- "-j$(nproc)"
45+
46+
WORKDIR /work/libvpx
47+
RUN ["git", "clone", "--branch=v1.13.1", "--depth=1", "https://github.com/webmproject/libvpx", "/work/libvpx"]
48+
RUN ["./configure", "--disable-shared", "--enable-static", "--disable-examples", "--disable-tools", "--disable-unit-tests"]
49+
RUN make "-j$(nproc)" install
50+
51+
WORKDIR /work/opus
52+
RUN ["git", "clone", "--branch=v1.4", "--depth=1", "https://github.com/xiph/opus", "/work/opus"]
53+
RUN ["autoreconf", "-fi"]
54+
RUN ["./configure", "--disable-shared", "--enable-static"]
55+
RUN make "-j$(nproc)" install
56+
57+
WORKDIR /app
58+
# TODO(iphydf): Change to a release tag once NGC is released.
59+
RUN ["git", "clone", "--branch=master", "--depth=1", "--recurse-submodules", "--shallow-submodules", "https://github.com/TokTok/c-toxcore", "/work/c-toxcore"]
60+
RUN mkdir -p /work/include/tox \
61+
&& ln -s /work/c-toxcore/toxav/toxav.h /work/include/tox/ \
62+
&& ln -s /work/c-toxcore/toxcore/tox.h /work/include/tox/ \
63+
&& ln -s /work/c-toxcore/toxencryptsave/toxencryptsave.h /work/include/tox/
64+
COPY src/ /work/toxic/src/
65+
RUN gcc \
66+
-o /app/toxic \
67+
-static \
68+
-DPACKAGE_DATADIR='"/app"' \
69+
-DGAMES \
70+
-DAUDIO \
71+
-DVIDEO \
72+
-DPYTHON \
73+
/work/toxic/src/*.c \
74+
/work/c-toxcore/toxav/*.c \
75+
/work/c-toxcore/toxcore/*.c \
76+
/work/c-toxcore/toxcore/*/*.c \
77+
/work/c-toxcore/toxencryptsave/*.c \
78+
/work/c-toxcore/third_party/cmp/cmp.c \
79+
-I/work/include \
80+
$(pkg-config --cflags --libs libconfig libcurl libsodium ncurses openal opus vpx) \
81+
$(python3-config --embed --abiflags --includes --ldflags) \
82+
"-L$(dirname $(find /usr -name "libpython3.11.a"))" \
83+
-lX11 -lxcb -lXdmcp -lXau -lssl -lcrypto -lnghttp2 -lidn2 -lz -lunistring -lbrotlidec -lbrotlicommon -lcares -lstdc++ -lportaudio
84+
RUN strip /app/toxic
85+
COPY misc/nameservers /app/
86+
COPY sounds/ /app/sounds/
87+
COPY apidoc/python/source/*.py /app/scripts/
88+
89+
RUN echo 'root:x:0:0:root:/root:/app/toxic' > /work/passwd \
90+
&& echo 'toxic:x:1000:1000:Toxic User:/home/toxic:/app/toxic' > /work/passwd \
91+
&& echo 'root:x:0' > /work/group \
92+
&& echo 'toxic:x:1000' > /work/group
93+
RUN mkdir -p /home/toxic/.config
94+
95+
FROM scratch
96+
# Basic OS-level stuff: passwd/group so we don't need to run as root, ssl for
97+
# curl to work, and terminfo for ncurses to work.
98+
COPY --from=build /work/passwd /work/group /etc/
99+
COPY --from=build /etc/ssl/ /etc/ssl/
100+
COPY --from=build /etc/terminfo/ /etc/terminfo/
101+
COPY --from=build /usr/lib/python3.11/ /usr/lib/python3.11/
102+
103+
# App bundle. Everything needed to run toxic is here.
104+
COPY --from=build /app /app
105+
106+
COPY --from=build --chown=toxic:toxic /home/toxic/ /home/toxic/
107+
WORKDIR /app
108+
USER toxic
109+
ENV USER=toxic
110+
CMD ["/app/toxic"]

Diff for: script/build-full-static-toxic.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
3+
set -eux
4+
5+
CONTAINER=toxic-static-build
6+
7+
docker build -t toxchat/toxic:latest -f script/Dockerfile .
8+
docker rm "$CONTAINER" || true # delete leftover container
9+
docker run --name "$CONTAINER" --detach toxchat/toxic:latest
10+
docker cp "$CONTAINER:/app/toxic" "$PWD/toxic-static"
11+
docker rm "$CONTAINER"

0 commit comments

Comments
 (0)