-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
143 lines (104 loc) · 4.53 KB
/
Dockerfile
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
# For mage
ARG PY_VERSION_DEFAULT=3.9
FROM debian:bullseye as base
ARG TARGETARCH
ARG PY_VERSION_DEFAULT
ENV PY_VERSION ${PY_VERSION_DEFAULT}
# Essentials for production
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` \
supervisor `memgraph`\
netcat `memgraph-platform` \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
###################################################################################################################################################
# MAGE
FROM base as mage-dev
WORKDIR /mage
COPY mage /mage
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN python3 -m pip install --upgrade pip \
&& python3 -m pip install --default-timeout=1000 -r /mage/python/requirements.txt
RUN python3 -m pip --default-timeout=1000 --no-cache-dir install torch-sparse torch-cluster torch-spline-conv \
torch-geometric torch-scatter -f https://data.pyg.org/whl/torch-1.12.0+cu102.html
RUN python3 /mage/setup build -p /usr/lib/memgraph/query_modules/
# 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
###################################################################################################################################################
# Lab: Build backend
FROM node:18.15-alpine as lab-base
WORKDIR /app
# Python make and g++ are needed for arm node-gyp package
RUN apk update && apk add git python3 make g++
ARG NPM_PACKAGE_TOKEN
COPY lab/frontend/.npmrc ./frontend/
COPY lab/frontend/package*.json ./frontend/
RUN echo '//npm.pkg.github.com/:_authToken=${NPM_PACKAGE_TOKEN}' | tee -a ./frontend/.npmrc
COPY lab/package*.json ./
RUN npm config rm proxy
RUN npm config rm https-proxy
RUN npm config set legacy-peer-deps true
RUN npm install && npm cache clean --force
RUN rm -f ./frontend/.npmrc
COPY lab/tsconfig.json .
COPY lab/tsconfig.build.json .
COPY lab/.env .
RUN sed -i "s/NODE_ENV=local/NODE_ENV=platform/" ./.env
COPY lab/backend/ ./backend/
COPY lab/frontend/ ./frontend/
RUN npm run build
RUN cd frontend && npm run build:production
###################################################################################################################################################
FROM base as final
# Copy the backend artifacts
COPY --from=lab-base /app/dist-backend /lab/dist-backend
COPY --from=lab-base /app/dist-frontend /lab/dist-frontend
COPY --from=lab-base /app/node_modules /lab/node_modules
COPY --from=lab-base /app/.env /lab/.env
# This is needed for lab
RUN apt-get update \
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# This is needed for memgraph built in algos
RUN pip3 install --default-timeout=1000 networkx==2.4 numpy==1.21.4 scipy==1.7.3
#copy modules
COPY --from=mage-dev /usr/lib/memgraph/query_modules/ /usr/lib/memgraph/query_modules/
# rm modules with issues (temporary)
RUN rm /usr/lib/memgraph/query_modules/node_classification.py \
&& rm /usr/lib/memgraph/query_modules/link_prediction.py \
&& rm /usr/lib/memgraph/query_modules/text.so
#copy python build
COPY --from=mage-dev /usr/local/lib/python${PY_VERSION}/ /usr/local/lib/python${PY_VERSION}/
COPY memgraph-${TARGETARCH}.deb .
RUN dpkg -i memgraph-${TARGETARCH}.deb && rm memgraph-${TARGETARCH}.deb
RUN rm -rf /mage \
&& 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
EXPOSE 3000 7444 7687
COPY configs/ /etc/supervisor/
RUN chmod 777 -R /var/log/memgraph
RUN chmod 777 -R /var/lib/memgraph
RUN chmod 777 -R /usr/lib/memgraph
RUN chmod 777 /usr/lib/memgraph/memgraph
ENV MEMGRAPH="--also-log-to-stderr"
ENTRYPOINT [ "/usr/bin/supervisord" ]
CMD [ "-c", "/etc/supervisor/supervisord.conf" ]