Skip to content

Commit

Permalink
test: Add a fully static build with A/V support.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Dec 31, 2023
1 parent 57d330c commit 59f0215
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,13 @@ jobs:
- name: Print log
run:
cat /__w/toxic/toxic/infer-out/report.txt

docker-static:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build docker image
uses: docker/build-push-action@v4
with:
tags: toxchat/toxic
104 changes: 104 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
FROM alpine:3.19.0 AS build

RUN ["apk", "add", "--no-cache", \
"autoconf", \
"automake", \
"brotli-static", \
"c-ares-static", \
"cmake", \
"curl-dev", \
"curl-static", \
"diffutils", \
"g++", \
"gcc", \
"git", \
"libconfig-dev", \
"libconfig-static", \
"libidn2-static", \
"libsodium-dev", \
"libsodium-static", \
"libtool", \
"libunistring-static", \
"libx11-dev", \
"libx11-static", \
"libxcb-static", \
"linux-headers", \
"make", \
"ncurses-dev", \
"ncurses-static", \
"nghttp2-static", \
"openssl-libs-static", \
"pkgconfig", \
"python3-dev", \
"yasm", \
"zlib-static"]

WORKDIR /work/portaudio
RUN ["git", "clone", "--branch=v19.7.0", "--depth=1", "https://github.com/PortAudio/portaudio", "/work/portaudio"]
RUN ["cmake", "-B_build", "-H.", "-DBUILD_SHARED_LIBS=OFF"]
RUN cmake --build _build --target install -- "-j$(nproc)"

WORKDIR /work/openal-soft
RUN ["git", "clone", "--branch=1.23.1", "--depth=1", "https://github.com/kcat/openal-soft", "/work/openal-soft"]
RUN ["cmake", "-B_build", "-H.", "-DLIBTYPE=STATIC", "-DALSOFT_EXAMPLES=OFF", "-DALSOFT_UTILS=OFF", "-DALSOFT_DLOPEN=OFF"]
RUN cmake --build _build --target install -- "-j$(nproc)"

WORKDIR /work/libvpx
RUN ["git", "clone", "--branch=v1.13.1", "--depth=1", "https://github.com/webmproject/libvpx", "/work/libvpx"]
RUN ["./configure", "--disable-shared", "--enable-static", "--disable-examples", "--disable-tools", "--disable-unit-tests"]
RUN make "-j$(nproc)" install

WORKDIR /work/opus
RUN ["git", "clone", "--branch=v1.4", "--depth=1", "https://github.com/xiph/opus", "/work/opus"]
RUN ["autoreconf", "-fi"]
RUN ["./configure", "--disable-shared", "--enable-static"]
RUN make "-j$(nproc)" install

WORKDIR /app
# TODO(iphydf): Change to a release tag once NGC is released.
RUN ["git", "clone", "--branch=master", "--depth=1", "--recurse-submodules", "--shallow-submodules", "https://github.com/TokTok/c-toxcore", "/work/c-toxcore"]
RUN mkdir -p /work/include/tox \
&& ln -s /work/c-toxcore/toxav/toxav.h /work/include/tox/ \
&& ln -s /work/c-toxcore/toxcore/tox.h /work/include/tox/ \
&& ln -s /work/c-toxcore/toxencryptsave/toxencryptsave.h /work/include/tox/
COPY src/ /work/toxic/src/
RUN gcc \
-o /app/toxic \
-static \
-DPACKAGE_DATADIR='"/app"' \
-DGAMES \
-DAUDIO \
-DVIDEO \
-DPYTHON \
/work/toxic/src/*.c \
/work/c-toxcore/toxav/*.c \
/work/c-toxcore/toxcore/*.c \
/work/c-toxcore/toxcore/*/*.c \
/work/c-toxcore/toxencryptsave/*.c \
/work/c-toxcore/third_party/cmp/cmp.c \
-I/work/include \
$(pkg-config --cflags --libs libconfig libcurl libsodium ncurses openal opus vpx) \
$(python3-config --embed --abiflags --includes --ldflags) \
"-L$(dirname $(find /usr -name "libpython3.11.a"))" \
-lX11 -lxcb -lXdmcp -lXau -lssl -lcrypto -lnghttp2 -lidn2 -lz -lunistring -lbrotlidec -lbrotlicommon -lcares -lstdc++ -lportaudio
RUN strip /app/toxic
COPY misc/nameservers /app/
COPY sounds/ /app/sounds/
COPY apidoc/python/source/*.py /app/scripts/

RUN echo 'root:x:0:0:root:/root:/app/toxic' > /work/passwd \
&& echo 'toxic:x:1000:1000:Toxic User:/home/toxic:/app/toxic' > /work/passwd \
&& echo 'root:x:0' > /work/group \
&& echo 'toxic:x:1000' > /work/group
RUN mkdir -p /home/toxic/.config

FROM scratch
COPY --from=build /work/passwd /work/group /etc/
COPY --from=build /etc/ssl/ /etc/ssl/
COPY --from=build /etc/terminfo/ /etc/terminfo/
COPY --from=build /usr/lib/python3.11/ /usr/lib/python3.11/
COPY --from=build --chown=toxic:toxic /home/toxic/ /home/toxic/
COPY --from=build /app /app
WORKDIR /app
USER toxic
CMD ["/app/toxic"]

0 comments on commit 59f0215

Please sign in to comment.