-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathDockerfile.release
223 lines (179 loc) · 7.68 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
ARG PY_VERSION_DEFAULT=3.12
ARG MGBUILD_IMAGE
FROM $MGBUILD_IMAGE as builder
USER root
ARG TARGETARCH
ARG PY_VERSION_DEFAULT
ARG BUILD_TYPE
ARG CACHE_PRESENT
ENV BUILD_TYPE=${BUILD_TYPE}
ENV PY_VERSION ${PY_VERSION_DEFAULT}
ENV TORCH_VERSION=2.4.0
# 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` \
uuid-dev \
gdb \
procps \
libc6-dbg \
libxmlsec1-dev xmlsec1 \
--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 .
RUN dpkg -i memgraph-${TARGETARCH}.deb && rm memgraph-${TARGETARCH}.deb
# move memgraph HOME so that mounting /var/lib/memgraph as a volume doesn't break Python
RUN mkdir -pv /home/memgraph && \
usermod -d /home/memgraph memgraph && \
chown -R memgraph:memgraph /home/memgraph
ENV LD_LIBRARY_PATH /usr/lib/memgraph/query_modules
WORKDIR /mage
COPY . /mage
#hacks so we can do everything under the `memgraph` user
RUN chown -R memgraph: /mage && \
mkdir -pv /usr/lib/memgraph/query_modules && \
chown -R memgraph: /usr/lib/memgraph/query_modules
USER memgraph
# First install requirements
RUN python3 -m pip install --no-cache-dir -r /mage/python/requirements.txt --break-system-packages && \
python3 -m pip install --no-cache-dir -r /mage/python/tests/requirements.txt --break-system-packages && \
python3 -m pip install --no-cache-dir -r /usr/lib/memgraph/auth_module/requirements.txt --break-system-packages && \
if [ "$TARGETARCH" = "arm64" ]; then \
if [ "$CACHE_PRESENT" = "true" ]; then \
echo "Using cached torch packages"; \
python3 -m pip install --no-index --find-links=/mage/wheels/ torch-sparse torch-cluster torch-spline-conv torch-geometric torch-scatter --break-system-packages; \
else \
python3 -m pip install --no-cache-dir torch-sparse torch-cluster torch-spline-conv torch-geometric torch-scatter -f https://data.pyg.org/whl/torch-2.4.0+cpu.html --break-system-packages; \
fi && \
curl -o dgl-2.4.0-cp312-cp312-linux_aarch64.whl https://s3.eu-west-1.amazonaws.com/deps.memgraph.io/memgraph-unofficial/dgl-2.4.0-cp312-cp312-linux_aarch64.whl && \
python3 -m pip install --no-cache-dir dgl-2.4.0-cp312-cp312-linux_aarch64.whl --break-system-packages; \
else \
if [ "$CACHE_PRESENT" = "true" ]; then \
echo "Using cached torch packages"; \
python3 -m pip install --no-index --find-links=/mage/wheels/ torch-sparse torch-cluster torch-spline-conv torch-geometric torch-scatter --break-system-packages; \
else \
python3 -m pip install --no-cache-dir torch-sparse torch-cluster torch-spline-conv torch-geometric torch-scatter -f https://data.pyg.org/whl/torch-2.4.0+cpu.html --break-system-packages; \
fi && \
python3 -m pip install --no-cache-dir dgl==2.4.0 -f https://data.dgl.ai/wheels/torch-2.4/repo.html --break-system-packages; \
fi && \
rm -fr /home/memgraph/.cache/pip
# Build query modules
SHELL ["/bin/bash", "-c"]
RUN source /opt/toolchain-v6/activate && curl https://sh.rustup.rs -sSf | sh -s -- -y \
&& export PATH="$HOME/.cargo/bin:${PATH}" \
&& rustup toolchain install 1.85 \
&& rustup default 1.85 \
&& python3 /mage/setup build -p /usr/lib/memgraph/query_modules/ --cpp-build-flags CMAKE_BUILD_TYPE=${BUILD_TYPE} \
&& chown -R memgraph: /mage
# Memgraph listens for Bolt Protocol on this port by default.
EXPOSE 7687
FROM ubuntu:24.04 as base
USER root
ARG TARGETARCH
ARG PY_VERSION_DEFAULT=3.12
ARG MAGE_COMMIT
ARG BUILD_TYPE
ENV BUILD_TYPE=${BUILD_TYPE}
ENV PY_VERSION ${PY_VERSION_DEFAULT}
ENV MAGE_COMMIT=${MAGE_COMMIT}
# Essentials for production/dev
RUN apt-get update && \
apt-get install -y curl && \
curl -sSL -O https://packages.microsoft.com/config/ubuntu/24.04/packages-microsoft-prod.deb && \
dpkg -i packages-microsoft-prod.deb && \
rm packages-microsoft-prod.deb && \
apt-get update && \
ACCEPT_EULA=Y apt-get install -y msodbcsql18 unixodbc-dev && \
apt-get install -y \
libcurl4 `memgraph` \
libpython${PY_VERSION} `memgraph` \
libssl-dev `memgraph` \
openssl `memgraph` \
python3 `mage-memgraph` \
python3-pip `mage-memgraph` \
python3-setuptools `mage-memgraph` \
python3-dev `mage-memgraph` \
libc6-dbg \
adduser \
libgomp1 \
libaio1t64 \
--no-install-recommends \
&& ln -s /usr/bin/$(ls /usr/bin | grep perf) /usr/bin/perf \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
if [ "${TARGETARCH}" = "arm64" ]; then \
ln -s /usr/lib/aarch64-linux-gnu/libaio.so.1t64 /usr/lib/aarch64-linux-gnu/libaio.so.1; \
else \
ln -s /usr/lib/x86_64-linux-gnu/libaio.so.1t64 /usr/lib/x86_64-linux-gnu/libaio.so.1; \
fi
# install memgraph
COPY memgraph-${TARGETARCH}.deb .
# fix `memgraph` UID and GID for compatibility with previous Debian releases
RUN groupadd -g 103 memgraph && \
useradd -u 101 -g memgraph -m -d /home/memgraph -s /bin/bash memgraph && \
dpkg -i memgraph-${TARGETARCH}.deb && \
rm memgraph-${TARGETARCH}.deb
ENV LD_LIBRARY_PATH /usr/lib/memgraph/query_modules
# Copy modules
COPY --from=builder /usr/lib/memgraph/query_modules/ /usr/lib/memgraph/query_modules/
COPY --from=builder /usr/lib/memgraph/auth_module/ /usr/lib/memgraph/auth_module/
# Copy Python build
COPY --from=builder /usr/local/lib/python${PY_VERSION}/ /usr/local/lib/python${PY_VERSION}/
COPY --from=builder --chown=memgraph:memgraph /home/memgraph/.local/ /home/memgraph/.local/
# copy script to convert to dev container
COPY --from=builder /mage/make-dev-container.sh /make-dev-container.sh
FROM base as prod
USER root
ARG TARGETARCH
ARG PY_VERSION_DEFAULT=3.12
ARG MAGE_COMMIT
ARG BUILD_TYPE
ENV BUILD_TYPE=${BUILD_TYPE}
ENV PY_VERSION ${PY_VERSION_DEFAULT}
ENV MAGE_COMMIT=${MAGE_COMMIT}
# Copy e2e tests
COPY --from=builder --chown=memgraph:memgraph /mage/e2e/ /mage/e2e/
COPY --from=builder --chown=memgraph:memgraph /mage/e2e_correctness/ /mage/e2e_correctness/
COPY --from=builder --chown=memgraph:memgraph /mage/test_e2e_correctness.py /mage/test_e2e_correctness.py
COPY --from=builder --chown=memgraph:memgraph /mage/run_e2e_correctness_tests.sh /mage/run_e2e_correctness_tests.sh
# Copy requirements
COPY --from=builder --chown=memgraph:memgraph /mage/python/requirements.txt /mage/python/requirements.txt
COPY --from=builder --chown=memgraph:memgraph /mage/python/tests/requirements.txt /mage/python/tests/requirements.txt
USER memgraph
EXPOSE 7687
ENTRYPOINT ["/usr/lib/memgraph/memgraph"]
CMD [""]
FROM base as debug
USER root
ARG TARGETARCH
ARG PY_VERSION_DEFAULT=3.12
ARG MAGE_COMMIT
ARG BUILD_TYPE
ENV BUILD_TYPE=${BUILD_TYPE}
ENV PY_VERSION ${PY_VERSION_DEFAULT}
ENV MAGE_COMMIT=${MAGE_COMMIT}
# Add gdb
RUN apt-get update && apt-get install -y \
gdb \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Copy entire mage repo
COPY --from=builder --chown=memgraph:memgraph /mage/ /mage/
USER memgraph
EXPOSE 7687
ENTRYPOINT ["/usr/lib/memgraph/memgraph"]
CMD [""]