diff --git a/.dockerignore b/.dockerignore index b5bff56b..78ae78ea 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,4 @@ build CMakeCache.txt ws/CMakeCache.txt +test/build diff --git a/DOCKER_VERSION b/DOCKER_VERSION index 227cea21..c043eea7 100644 --- a/DOCKER_VERSION +++ b/DOCKER_VERSION @@ -1 +1 @@ -2.0.0 +2.2.1 diff --git a/Dockerfile b/Dockerfile index cd238cbd..197ac830 120000 --- a/Dockerfile +++ b/Dockerfile @@ -1 +1 @@ -docker/Dockerfile.ubuntu_xenial \ No newline at end of file +docker/Dockerfile.alpine \ No newline at end of file diff --git a/docker/Dockerfile.alpine b/docker/Dockerfile.alpine new file mode 100644 index 00000000..1cf01e0c --- /dev/null +++ b/docker/Dockerfile.alpine @@ -0,0 +1,33 @@ +FROM alpine as build + +RUN apk add --no-cache gcc g++ musl-dev linux-headers cmake openssl-dev +RUN apk add --no-cache make +RUN apk add --no-cache zlib-dev + +RUN addgroup -S app && adduser -S -G app app +RUN chown -R app:app /opt +RUN chown -R app:app /usr/local + +# There is a bug in CMake where we cannot build from the root top folder +# So we build from /opt +COPY --chown=app:app . /opt +WORKDIR /opt + +USER app +RUN [ "make" ] + +FROM alpine as runtime + +RUN apk add --no-cache libstdc++ + +RUN addgroup -S app && adduser -S -G app app +COPY --chown=app:app --from=build /usr/local/bin/ws /usr/local/bin/ws +RUN chmod +x /usr/local/bin/ws +RUN ldd /usr/local/bin/ws + +# Now run in usermode +USER app +WORKDIR /home/app + +ENTRYPOINT ["ws"] +CMD ["--help"] diff --git a/makefile b/makefile index 044ae6d5..9c21162f 100644 --- a/makefile +++ b/makefile @@ -25,6 +25,9 @@ IMG := ${NAME}:${TAG} LATEST := ${NAME}:latest BUILD := ${NAME}:build +docker_test: + docker build -f docker/Dockerfile.debian -t bsergean/ixwebsocket_test:build . + docker: docker build -t ${IMG} . docker tag ${IMG} ${BUILD} @@ -34,7 +37,7 @@ docker_push: docker push ${LATEST} run: - docker run --cap-add sys_ptrace --entrypoint=bash -it bsergean/ws:build + docker run --cap-add sys_ptrace --entrypoint=sh -it bsergean/ws:build # this is helpful to remove trailing whitespaces trail: diff --git a/test/IXWebSocketPingTest.cpp b/test/IXWebSocketPingTest.cpp index 4ddd2e2f..7cd0a86d 100644 --- a/test/IXWebSocketPingTest.cpp +++ b/test/IXWebSocketPingTest.cpp @@ -427,6 +427,7 @@ TEST_CASE("Websocket_ping_no_data_sent_setHeartBeatPeriod", "[setHeartBeatPeriod REQUIRE(server.getClients().size() == 0); ix::reportWebSocketTraffic(); + server.stop(); } } @@ -477,5 +478,6 @@ TEST_CASE("Websocket_ping_data_sent_setHeartBeatPeriod", "[setHeartBeatPeriod]") REQUIRE(server.getClients().size() == 0); ix::reportWebSocketTraffic(); + server.stop(); } } diff --git a/ws/IXSentryClient.cpp b/ws/IXSentryClient.cpp index d89d0b0f..2d266713 100644 --- a/ws/IXSentryClient.cpp +++ b/ws/IXSentryClient.cpp @@ -99,6 +99,18 @@ namespace ix return frames; } + std::string parseExceptionName(const std::string& stack) + { + // Split by lines + std::string line; + std::stringstream tokenStream(stack); + + // Extract the first line + std::getline(tokenStream, line); + + return line; + } + std::string SentryClient::computePayload(const Json::Value& msg) { Json::Value payload; @@ -107,14 +119,14 @@ namespace ix payload["sdk"]["version"] = "1.0.0"; payload["timestamp"] = SentryClient::getIso8601(); + bool isNoisyTypes = msg["id"].asString() == "game_noisytypes_id"; + + std::string stackTraceFieldName = isNoisyTypes ? "traceback" : "stack"; + std::string stack(msg["data"][stackTraceFieldName].asString()); + Json::Value exception; - exception["value"] = msg["data"]["message"]; - - std::string stackTraceFieldName = - (msg["id"].asString() == "game_noisytypes_id") ? "traceback" : "stack"; - - exception["stacktrace"]["frames"] = - parseLuaStackTrace(msg["data"][stackTraceFieldName].asString()); + exception["stacktrace"]["frames"] = parseLuaStackTrace(stack); + exception["value"] = isNoisyTypes ? parseExceptionName(stack) : msg["data"]["message"]; payload["exception"].append(exception);