Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
RIAK_VERSION: 3.0.12
RIAK_VERSION: 3.2.2


jobs:
Expand Down
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ COPY files/poststart.d /tmp/portage-root/etc/riak/poststart.d
# Install custom start script
COPY files/riak-cluster.sh /tmp/portage-root/riak-cluster.sh


#####################################################################
# Riak image
FROM erlang:22-slim
Expand All @@ -26,14 +27,16 @@ FROM erlang:22-slim
# Create riak user/group
RUN adduser --uid 102 --gecos riak --disabled-password --home /var/lib/riak riak && \
mkdir -p /var/log/riak && \
chown -R 102:102 /var/log/riak
chown -R 102:102 /var/log/riak && \
apt-get update && \
apt-get install -y sudo

# Copy riak sources
COPY --chown=102:102 --from=build /tmp/portage-root/ /
COPY --from=build /opt/riak/_build/deb/rel/riak/lib /usr/lib/riak/lib
COPY --from=build /opt/riak/_build/deb/rel/riak/share /usr/lib/riak/share
COPY --from=build /opt/riak/_build/deb/rel/riak/releases /usr/lib/riak/releases
COPY --from=build /opt/riak/_build/deb/rel/riak/erts-10.7.2.18 /usr/lib/riak/erts-10.7.2.18
COPY --from=build /opt/riak/_build/deb/rel/riak/erts-10.7.2.19 /usr/lib/riak/erts-10.7.2.19
COPY --from=build /opt/riak/_build/deb/rel/riak/bin /usr/lib/riak/bin
COPY --chown=102:102 --from=build /opt/riak/_build/deb/rel/riak/etc/* /etc/riak/
COPY --chown=102:102 --from=build /opt/riak/_build/deb/rel/riak/data/* /var/lib/riak/data/
Expand Down
11 changes: 6 additions & 5 deletions files/install-riak.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ set -e eu

# Build riak
mkdir -p /opt/riak && cd /opt/riak
curl -L https://github.com/basho/riak/archive/refs/tags/riak-${RIAK_VERSION}.tar.gz -o /opt/riak.tar.gz
tar zxf /opt/riak.tar.gz --strip-components 1
patch -p0 < /riak.schema.patch
patch < /rebar.config.patch
patch < /rebar.lock.patch
curl -L https://github.com/nhs-riak/riak/archive/refs/tags/riak-${RIAK_VERSION}-nhse.tar.gz -o /opt/riak.tar.gz
tar xvf /opt/riak.tar.gz --strip-components 1
# patch -p0 < /riak.schema.patch
# patch < /rebar.config.patch
# patch < /rebar.lock.patch
make all
./rebar3 as deb release --overlay_vars /vars.config
ls -la /opt/riak/_build/deb/rel/riak
27 changes: 10 additions & 17 deletions files/rebar.config.patch
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
--- rebar.config.orig 2023-03-01 15:38:23.497209722 +0400
+++ rebar.config 2023-03-01 15:42:59.569322130 +0400
@@ -17,7 +17,8 @@

% {yokozuna, {git, "https://github.com/basho/yokozuna.git", {branch, "develop-3.0"}}},

- {riak_repl, {git, "https://github.com/basho/riak_repl.git", {tag, "riak_kv-3.0.12"}}}
+ {riak_repl, {git, "https://github.com/basho/riak_repl.git", {tag, "riak_kv-3.0.12"}}},
+ {lager_logstash_formatter, ".*", {git, "https://github.com/rbkmoney/lager_logstash_formatter.git", {branch, "riak-2.9"}}}
--- rebar.config.orig 2024-06-24 14:04:31
+++ rebar.config 2024-06-24 14:05:05
@@ -9,7 +9,9 @@
{deps, [
{riak_kv, {git, "https://github.com/nhs-riak/riak_kv", {branch, "nhse-develop"}}},
{riak_auth_mods, {git, "https://github.com/nhs-riak/riak_auth_mods", {branch, "nhse-develop"}}},
- {riak_repl, {git, "https://github.com/nhs-riak/riak_repl", {branch, "nhse-develop"}}}
+ {riak_repl, {git, "https://github.com/nhs-riak/riak_repl", {branch, "nhse-develop"}}},
+ {logger_logstash_formatter,
+ {git, "https://github.com/valitydev/logger_logstash_formatter.git", {ref, "08a66a6"}}}
]}.

{project_plugins, [
@@ -51,6 +52,7 @@
stdlib,
lager,
lager_syslog,
+ lager_logstash_formatter,
sasl,
public_key,
ssl,
48 changes: 30 additions & 18 deletions files/rebar.lock.patch
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
--- rebar.lock.orig 2023-03-01 15:38:30.045212676 +0400
+++ rebar.lock 2023-03-01 15:44:57.753364158 +0400
@@ -48,6 +48,10 @@
--- rebar.lock
+++ rebar.lock
@@ -50,6 +50,7 @@
{git,"https://github.com/basho/ibrowse.git",
{ref,"cdde6fe5e80ce71e7b5570e40a45d9f862721499"}},
2},
+ {<<"jsx">>,
+ {git,"https://github.com/talentdeficit/jsx.git",
+ {ref,"47ce39f040b5da98794008bf0126c8a68760d786"}},
+ 1},
+ {<<"jsx">>,{pkg,<<"jsx">>,<<"3.1.0">>},1},
{<<"kv_index_tictactree">>,
{git,"https://github.com/martinsumner/kv_index_tictactree.git",
{ref,"4cd9ab1e20772db36f593879272dff5f02fbbeda"}},
@@ -56,6 +60,10 @@
{git,"https://github.com/erlang-lager/lager.git",
{ref,"22e62f28e5afabe90a6f31bcde367a2b5799fc94"}},
1},
+ {<<"lager_logstash_formatter">>,
+ {git,"https://github.com/rbkmoney/lager_logstash_formatter.git",
+ {ref,"687b556a05f86f0c1640db992611cec821451fa4"}},
{ref,"493f94ba24028d823772665c244d33728eca2a6e"}},
@@ -58,6 +59,10 @@
{git,"https://github.com/martinsumner/leveled",
{ref,"a033e280e67931582cc9625993268db126abb4ff"}},
2},
+ {<<"logger_logstash_formatter">>,
+ {git,"https://github.com/valitydev/logger_logstash_formatter.git",
+ {ref,"08a66a6001ad5db73a05b836e7a0c9edb192532a"}},
+ 0},
{<<"lager_syslog">>,
{git,"https://github.com/basho/lager_syslog.git",
{ref,"5c8eb6ec82fa45ff0f4e456747e095654e342746"}},
{<<"lz4">>,
{git,"https://github.com/martinsumner/erlang-lz4",
{ref,"d407af5de71303b8e381df718d2e5d05eb775c59"}},
@@ -153,12 +158,14 @@
{<<"bear">>, <<"430419C1126B477686CDE843E88BA0F2C7DC5CDF0881C677500074F704339A99">>},
{<<"folsom">>, <<"50ECC998D2149939F1D5E0AA3E32788F8ED16A58E390D81B5C0BE4CC4EF25589">>},
{<<"hut">>, <<"71F2F054E657C03F959CF1ACC43F436EA87580696528CA2A55C8AFB1B06C85E7">>},
+ {<<"jsx">>, <<"D12516BAA0BB23A59BB35DCCAF02A1BD08243FCBB9EFE24F2D9D056CCFF71268">>},
{<<"parse_trans">>, <<"6E6AA8167CB44CC8F39441D05193BE6E6F4E7C2946CB2759F015F8C56B76E5FF">>},
{<<"setup">>, <<"05F69185A5EB71474C9BC6BA892565651EC7507791F85632B7B914DBFE130510">>}]},
{pkg_hash_ext,[
{<<"bear">>, <<"157B67901ADF84FF0DA6EAE035CA1292A0AC18AA55148154D8C582B2C68959DB">>},
{<<"folsom">>, <<"DD6AB97278E94F9E4CFC43E188224A7B8C7EAEC0DD2E935007005177F3EEBB0E">>},
{<<"hut">>, <<"7E15D28555D8A1F2B5A3A931EC120AF0753E4853A4C66053DB354F35BF9AB563">>},
+ {<<"jsx">>, <<"0C5CC8FDC11B53CC25CF65AC6705AD39E54ECC56D1C22E4ADB8F5A53FB9427F3">>},
{<<"parse_trans">>, <<"620A406CE75DADA827B82E453C19CF06776BE266F5A67CFF34E1EF2CBB60E49A">>},
{<<"setup">>, <<"EFD072578F0CF85BEA96CAAFFC7ADB0992398272522660A136E10567377071C5">>}]}
].
69 changes: 51 additions & 18 deletions files/riak.schema.patch
Original file line number Diff line number Diff line change
@@ -1,18 +1,51 @@
--- priv/riak.schema.orig 2023-03-01 15:38:54.733223673 +0400
+++ priv/riak.schema 2023-03-01 15:58:16.673602387 +0400
@@ -74,6 +74,7 @@
undefined -> [];
ErrorFilename -> [{lager_file_backend, [{file, ErrorFilename},
{level, error},
+ {formatter, lager_logstash_formatter},
{size, 10485760},
{date, "$D0"},
{count, 5}]}]
@@ -85,6 +86,7 @@
ConsoleHandler = {lager_console_backend, ConsoleLogLevel},
ConsoleFileHandler = {lager_file_backend, [{file, ConsoleLogFile},
{level, ConsoleLogLevel},
+ {formatter, lager_logstash_formatter},
{size, 10485760},
{date, "$D0"},
{count, 5}]},
--- priv/riak.schema.origin 2024-06-28 14:44:19
+++ priv/riak.schema 2024-06-28 14:54:04
@@ -11,9 +11,11 @@
%% and atoms. The atoms denote the keys for retrieving metadata from the logger events.
%% More information on default metadata can be found here (https://www.erlang.org/doc/man/logger_formatter.html#type-template).
{mapping, "logger.format", "kernel.logger", [
- {default, "[time,\" [\",level,\"] \",pid,\"@\",mfa,\":\",line,\" \",msg,\"\\n\"]."}
+ {default, "{\"time\": \"~s\", \"level\": \"~s\", \"pid\": \"~p\", \"mfa\": \"~p\", \"line\": \"~p\", \"msg\": \"~s\"}"},
+ {datatype, string}
]}.

+
%% @doc Filename to use for log files.
{mapping, "logger.file", "kernel.logger", [
{default, "$(platform_log_dir)/console.log"},
\ No newline at end of file
@@ -42,31 +44,19 @@
MaxNumFiles = cuttlefish:conf_get("logger.max_files", Conf),

DefaultFormatStr = cuttlefish:conf_get("logger.format", Conf),
- DefaultFormatTerm =
- case erl_scan:string(DefaultFormatStr) of
- {ok, DefaultTokens, _} ->
- case erl_parse:parse_term(DefaultTokens) of
- {ok, DefaultTerm} ->
- DefaultTerm;
- {error, {_, _, DefaultError}} ->
- cuttlefish:error(foo)
- end;
- {error, {_, _, DefaultScanError}} ->
- cuttlefish:error(foo)
- end,
ConfigMap0 = #{config => #{file => LogFile,
max_no_bytes => MaxNumBytes,
max_no_files => MaxNumFiles},
formatter => {logger_formatter,
- #{template => DefaultFormatTerm}
+ #{template => DefaultFormatStr}
}
},

[{handler, default, logger_std_h, ConfigMap0}]
-
end
}.

+
%% @doc Cookie for distributed node communication. All nodes in the
%% same cluster should use the same cookie or they will not be able to
%% communicate.
\ No newline at end of file
3 changes: 0 additions & 3 deletions files/vars.config
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@
{yz_solr_port, 8093}.
{yz_solr_jmx_port, 8985}.

%% lager
{console_log_default, file}.

%%
%% etc/vm.args
%%
Expand Down