-
Notifications
You must be signed in to change notification settings - Fork 28
/
Dockerfile.release
105 lines (81 loc) · 3.21 KB
/
Dockerfile.release
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
ARG PY_VERSION_DEFAULT=3.9
FROM debian:bullseye as base
USER root
ARG TARGETARCH
ARG PY_VERSION_DEFAULT
ENV PY_VERSION ${PY_VERSION_DEFAULT}
#essentials for production/dev
RUN apt-get update && apt-get install -y \
libcurl4 `memgraph` \
libpython${PY_VERSION} `memgraph` \
libssl-dev `memgraph` \
openssl `memgraph` \
build-essential `mage-memgraph` \
cmake `mage-memgraph` \
curl `mage-memgraph` \
g++ `mage-memgraph` \
python3 `mage-memgraph` \
python3-pip `mage-memgraph` \
python3-setuptools `mage-memgraph` \
python3-dev `mage-memgraph` \
clang `mage-memgraph` \
git `mage-memgraph` \
unixodbc-dev `mage-memgraph` \
libboost-all-dev `mage-memgraph` \
gdb \
procps \
linux-perf \
libc6-dbg \
--no-install-recommends \
&& ln -s /usr/bin/$(ls /usr/bin | grep perf) /usr/bin/perf \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY memgraph-${TARGETARCH}.deb .
# Hack to remove modules that cause error on loading of torch modules
# Must be here due to multi-phase build. The setup script is in dev phase
# whereas we unpack memgraph in the base phase
RUN dpkg -i memgraph-${TARGETARCH}.deb && rm memgraph-${TARGETARCH}.deb
ENV LD_LIBRARY_PATH /usr/lib/memgraph/query_modules
# Memgraph listens for Bolt Protocol on this port by default.
EXPOSE 7687
FROM base as dev
ARG BUILD_TYPE=Release
WORKDIR /mage
COPY . /mage
#MAGE
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y \
&& export PATH="/root/.cargo/bin:${PATH}" \
&& python3 -m pip install -r /mage/python/requirements.txt \
&& python3 -m pip install -r /mage/python/tests/requirements.txt \
&& python3 -m pip install --no-cache-dir -r /usr/lib/memgraph/auth_module/requirements.txt \
&& python3 -m pip install torch-sparse torch-cluster torch-spline-conv torch-geometric torch-scatter -f https://data.pyg.org/whl/torch-1.12.0+cu102.html \
&& python3 /mage/setup build -p /usr/lib/memgraph/query_modules/ --cpp-build-flags CMAKE_BUILD_TYPE=${BUILD_TYPE} \
&& chown -R memgraph: /mage/e2e
#DGL build from source
RUN git clone --recurse-submodules -b 0.9.x https://github.com/dmlc/dgl.git \
&& cd dgl && mkdir build && cd build && cmake .. \
&& make -j4 && cd ../python && python3 setup.py install
USER memgraph
ENTRYPOINT ["/usr/lib/memgraph/memgraph"]
CMD [""]
FROM base as prod
USER root
ENTRYPOINT []
ARG PY_VERSION_DEFAULT
ENV PY_VERSION ${PY_VERSION_DEFAULT}
#copy modules
COPY --from=dev /usr/lib/memgraph/query_modules/ /usr/lib/memgraph/query_modules/
COPY --from=dev /usr/lib/memgraph/auth_module/ /usr/lib/memgraph/auth_module/
#copy python build
COPY --from=dev /usr/local/lib/python${PY_VERSION}/ /usr/local/lib/python${PY_VERSION}/
#copy e2e tests
COPY --from=dev /mage/e2e/ /mage/e2e/
RUN mv /mage/e2e /e2e/ \
&& rm -rf /mage/* \
&& mv /e2e/ /mage/ \
&& chown -R memgraph: /mage/e2e \
&& export PATH="/usr/local/lib/python${PY_VERSION}:${PATH}" \
&& apt-get -y --purge autoremove clang git curl python3-pip python3-dev cmake build-essential \
&& apt-get clean
USER memgraph
ENTRYPOINT ["/usr/lib/memgraph/memgraph"]
CMD [""]