Skip to content
This repository was archived by the owner on Apr 20, 2020. It is now read-only.

Commit b3ca97b

Browse files
committed
Add Dockerfile
1 parent 6b71a3d commit b3ca97b

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM rust:latest as builder
2+
3+
ENV LIBDIR /usr/lib/redis/modules
4+
ENV DEPS "python python-setuptools python-pip wget unzip build-essential clang-6.0 cmake"
5+
# Set up a build environment
6+
RUN set -ex;\
7+
deps="$DEPS";\
8+
apt-get update; \
9+
apt-get install -y --no-install-recommends $deps;\
10+
pip install rmtest;
11+
12+
# Build the source
13+
ADD . /REJSON
14+
WORKDIR /REJSON
15+
RUN set -ex;\
16+
cargo build --release; \
17+
python ./test/pytest/test.py target/release/libredisjson.so;
18+
19+
# Package the runner
20+
FROM redis:latest
21+
ENV LIBDIR /usr/lib/redis/modules
22+
WORKDIR /data
23+
RUN set -ex;\
24+
mkdir -p "$LIBDIR";
25+
COPY --from=builder /REJSON/target/release/libredisjson.so "$LIBDIR"
26+
27+
CMD ["redis-server", "--loadmodule", "/usr/lib/redis/modules/libredisjson.so"]

test/pytest/test.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import redis
66
import unittest
77
import json
8+
import sys
89
import os
910

1011
# Path to JSON test case files
@@ -66,7 +67,13 @@
6667
},
6768
}
6869

69-
rmtest.config.REDIS_MODULE = os.path.abspath(os.path.join(os.getcwd(), 'target/debug/libredisjson.so'))
70+
if len(sys.argv) >= 2:
71+
lib_file = sys.argv[1]
72+
del sys.argv[1:]
73+
else:
74+
lib_file = 'target/debug/libredisjson.so'
75+
76+
rmtest.config.REDIS_MODULE = os.path.abspath(os.path.join(os.getcwd(), lib_file))
7077

7178
class BaseReJSONTest(BaseModuleTestCase):
7279
def getCacheInfo(self):
@@ -76,9 +83,6 @@ def getCacheInfo(self):
7683
ret[res[x]] = res[x+1]
7784
return ret
7885

79-
80-
81-
8286
class ReJSONTestCase(BaseReJSONTest):
8387
"""Tests ReJSON Redis module in vitro"""
8488

@@ -887,4 +891,4 @@ def testDoubleParse(self):
887891
# self.assertEqual(0, cacheItems())
888892

889893
if __name__ == '__main__':
890-
unittest.main()
894+
unittest.main()

0 commit comments

Comments
 (0)