forked from JFreegman/toxic
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add a fully static build with A/V support.
- Loading branch information
Showing
2 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |