#2 - Docker building for older glibc

This commit was merged in pull request #4.
This commit is contained in:
Martin Slachta
2026-08-05 09:53:07 +02:00
parent 2f0662e2bb
commit 2e95c941ba
12 changed files with 280 additions and 141 deletions
@@ -49,7 +49,9 @@ Instance create_instance(const std::string& name, const lft::win::Window* window
// required_extensions.push_back(VK_EXT_ROBUSTNESS_2_EXTENSION_NAME);
std::vector<std::string> required_layers = {
#if DEBUG
"VK_LAYER_KHRONOS_validation"
#endif
};
/**
+1 -1
View File
@@ -2,7 +2,7 @@
#include <cstring>
#include <functional>
#include <fmt/format.h>
#include <spdlog/fmt/fmt.h>
namespace tw::net {
+71 -71
View File
@@ -1,71 +1,71 @@
#include <barrier>
#include <catch2/catch_test_macros.hpp>
#include <span>
#include <iostream>
#include "UdpStream.hpp"
#include "Address.hpp"
#include "quicr/QuicrConnection.hpp"
#include "quicr/QuicrConnectionListener.hpp"
#include "quicr/QuicrEndpoint.hpp"
TEST_CASE("Start two sockets and send message", "[udp]") {
std::barrier create_sync_point(2);
std::barrier send_sync_point(2);
const std::string message = "Hello, server!";
std::thread server_thread([&]() {
auto r = tw::net::UdpStream::bind(tw::net::Address {"127.0.0.1", 6969});
if(!r.has_value()) {
std::cout << ("Failed to bind UDP stream: {}") << r.error().message() << std::endl;
}
auto flag_result = r->set_non_blocking();
auto server = std::move(r.value());
create_sync_point.arrive_and_wait();
send_sync_point.arrive_and_wait();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
std::vector<std::byte> buffer(1024);
tw::net::Address from {{}, 0};
auto read_result = server.read_into(std::span{buffer.data(), buffer.size()}, &from);
if(!read_result.has_value()) {
spdlog::error("Failed to read from UDP stream: {}", read_result.error().message());
}
// convert the buffer to a string
std::string mesg(buffer.data(), buffer.data() + read_result.value());
REQUIRE(mesg == message);
});
std::thread client_thread([&]() {
create_sync_point.arrive_and_wait();
auto connect_result = tw::net::UdpStream::to(tw::net::Address{"127.0.0.1", 6969});
if(!connect_result.has_value()) {
spdlog::error("Failed to bind UDP stream: {}", connect_result.error().mesg());
}
auto client = std::move(connect_result.value());
std::string mesg = message;
auto write_result = client.write(std::as_writable_bytes(std::span(mesg.begin(), mesg.end())));
if(!write_result.has_value() && write_result.value() == mesg.length()) {
spdlog::error("Failed to write to UDP stream: {}", write_result.error().message());
}
send_sync_point.arrive_and_wait();
});
server_thread.join();
client_thread.join();
}
using namespace tw::net;
using namespace tw::net::quicr;
// #include <barrier>
// #include <catch2/catch_test_macros.hpp>
// #include <span>
// #include <iostream>
//
// #include "UdpStream.hpp"
// #include "Address.hpp"
// #include "quicr/QuicrConnection.hpp"
// #include "quicr/QuicrConnectionListener.hpp"
// #include "quicr/QuicrEndpoint.hpp"
//
// TEST_CASE("Start two sockets and send message", "[udp]") {
// std::barrier create_sync_point(2);
// std::barrier send_sync_point(2);
//
// const std::string message = "Hello, server!";
//
// std::thread server_thread([&]() {
// auto r = tw::net::UdpStream::bind(tw::net::Address {"127.0.0.1", 6969});
// if(!r.has_value()) {
// std::cout << ("Failed to bind UDP stream: {}") << r.error().message() << std::endl;
// }
//
// auto flag_result = r->set_non_blocking();
//
// auto server = std::move(r.value());
//
// create_sync_point.arrive_and_wait();
// send_sync_point.arrive_and_wait();
//
// std::this_thread::sleep_for(std::chrono::milliseconds(100));
//
// std::vector<std::byte> buffer(1024);
// tw::net::Address from {{}, 0};
// auto read_result = server.read_into(std::span{buffer.data(), buffer.size()}, &from);
//
// if(!read_result.has_value()) {
// spdlog::error("Failed to read from UDP stream: {}", read_result.error().message());
// }
//
// // convert the buffer to a string
// std::string mesg(buffer.data(), buffer.data() + read_result.value());
// REQUIRE(mesg == message);
// });
//
// std::thread client_thread([&]() {
// create_sync_point.arrive_and_wait();
//
// auto connect_result = tw::net::UdpStream::to(tw::net::Address{"127.0.0.1", 6969});
// if(!connect_result.has_value()) {
// spdlog::error("Failed to bind UDP stream: {}", connect_result.error().mesg());
// }
//
// auto client = std::move(connect_result.value());
//
// std::string mesg = message;
// auto write_result = client.write(std::as_writable_bytes(std::span(mesg.begin(), mesg.end())));
//
// if(!write_result.has_value() && write_result.value() == mesg.length()) {
// spdlog::error("Failed to write to UDP stream: {}", write_result.error().message());
// }
//
// send_sync_point.arrive_and_wait();
// });
//
// server_thread.join();
// client_thread.join();
// }
//
// using namespace tw::net;
// using namespace tw::net::quicr;
@@ -1,6 +1,5 @@
#pragma once
#include <nlohmann/json.hpp>
#include "Serialization.hpp"
#include "Serializers.hpp"
-58
View File
@@ -1,58 +0,0 @@
# Build the toolchain stage on its own and pass it back in to skip the apt step:
# docker build -f modules/server/Dockerfile --target toolchain -t tw_toolchain .
# docker build -f modules/server/Dockerfile --build-arg TOOLCHAIN_IMAGE=tw_toolchain .
ARG TOOLCHAIN_IMAGE=toolchain
# ── toolchain stage ──────────────────────────────────────────────────────────
FROM ubuntu:24.04 AS toolchain
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
clang \
libstdc++-14-dev \
cmake \
ninja-build \
mold \
git \
ca-certificates \
pkg-config \
glslang-tools \
libvulkan-dev \
libsdl2-dev \
libprotobuf-dev protobuf-compiler \
libpq-dev \
libpqxx-dev \
&& rm -rf /var/lib/apt/lists/*
ENV CC=clang
ENV CXX=clang++
# ── build stage ──────────────────────────────────────────────────────────────
FROM ${TOOLCHAIN_IMAGE} AS builder
WORKDIR /src
COPY . .
# glm, entt, Jolt, spdlog, expected, Catch2 and tracy are cloned at configure time
RUN cmake -B /build -G Ninja -DCMAKE_BUILD_TYPE=Release \
&& cmake --build /build --target tw_server
# Stage the shared libraries the binary was linked against; the runtime image has
# no package manager. glibc and its loader stay behind, they come with that image.
RUN mkdir -p /rootfs/usr/lib/x86_64-linux-gnu \
&& ldd /build/modules/server/tw_server \
| awk '/=> \//{ print $3 }' \
| grep -vE '/(libc|libm|libdl|libpthread|librt|libresolv|libanl)\.so' \
| xargs -I{} cp -L {} /rootfs/usr/lib/x86_64-linux-gnu/
# ── runtime stage ─────────────────────────────────────────────────────────────
FROM gcr.io/distroless/cc-debian13:nonroot
COPY --from=builder /rootfs/ /
COPY --from=builder /build/modules/server/tw_server /usr/local/bin/tw_server
# player connections, zone-server peering
EXPOSE 8101/udp 8102/udp
ENTRYPOINT ["/usr/local/bin/tw_server"]