fix cobra to sentry + change ws docker file to use alpine (much smaller footprint)

This commit is contained in:
Benjamin Sergeant 2019-05-31 00:43:22 -07:00
parent c65fec7271
commit 285386e47f
7 changed files with 61 additions and 10 deletions

View File

@ -1,3 +1,4 @@
build
CMakeCache.txt
ws/CMakeCache.txt
test/build

View File

@ -1 +1 @@
2.0.0
2.2.1

View File

@ -1 +1 @@
docker/Dockerfile.ubuntu_xenial
docker/Dockerfile.alpine

33
docker/Dockerfile.alpine Normal file
View File

@ -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"]

View File

@ -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:

View File

@ -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();
}
}

View File

@ -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);