diff --git a/data-loading/Dockerfile b/data-loading/Dockerfile index 2463dcf..ca71a78 100644 --- a/data-loading/Dockerfile +++ b/data-loading/Dockerfile @@ -1,5 +1,5 @@ # Use Redis so we can redis-cli. -FROM redis:6 +FROM redis:latest # Configuration ARG ROOT=/home/nru @@ -8,6 +8,7 @@ ARG DATA=/data RUN apt-get update RUN apt-get -y upgrade RUN apt-get -y install wget python3-venv python3-pip +RUN apt-get -y install git gcc # Create nru user RUN mkdir -p ${ROOT} @@ -15,6 +16,12 @@ RUN useradd nru -d ${ROOT} RUN chown nru ${ROOT} WORKDIR ${ROOT} +# We need to install rdb-cli, which we need to -- lolsob -- compile from source. So let's do that. +RUN git clone https://github.com/redis/librdb.git +WORKDIR ${ROOT}/librdb +RUN make install +WORKDIR ${ROOT} + # Set up a volume for data. VOLUME ${DATA} RUN mkdir -p ${DATA} @@ -32,5 +39,11 @@ ENV PATH="${VIRTUAL_ENV}/bin:$PATH" COPY --chown=nru requirements.txt ${ROOT} RUN pip3 install -r requirements.txt +# Copy scripts. +COPY --chown=nru rdb-to-resp.sh ${ROOT} + +# Make sure rdb-cli has been set up. +# RUN rdb-cli + # Entrypoint should be bash. -ENTRYPOINT /bin/bash +ENTRYPOINT ["/bin/bash"] diff --git a/data-loading/rdb-to-resp.sh b/data-loading/rdb-to-resp.sh new file mode 100755 index 0000000..a81bbab --- /dev/null +++ b/data-loading/rdb-to-resp.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# +# A Bash script to convert an RDB file into a stream of RESP commands. +# Uses https://github.com/redis/librdb?tab=readme-ov-file#rdb-cli-usage +# +# bash rdb-to-resp.sh RDB_FILENAME [REDIS_VERSION] +set -euo pipefail + +# Check the number of arguments +if [ "$#" -lt 1 ]; then + echo "Usage: $0 " >&2 + exit 1 +fi +REDIS_VERSION="${2:-6.2}" # Default to a Redis version of 6.2 + +rdb-cli "$1" resp --target-redis-ver "${REDIS_VERSION}" \ No newline at end of file diff --git a/data-loading/requirements.txt b/data-loading/requirements.txt index ed096b4..8b13789 100644 --- a/data-loading/requirements.txt +++ b/data-loading/requirements.txt @@ -1,2 +1 @@ -rdbtools -python-lzf +