-
Notifications
You must be signed in to change notification settings - Fork 133
/
Dockerfile.indexer-agent
69 lines (49 loc) · 2.21 KB
/
Dockerfile.indexer-agent
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
########################################################################
# Build image
FROM node:20.11-bookworm-slim as build
ENV NODE_ENV production
RUN apt-get update && apt-get install -y python3 build-essential git curl
# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rustup.sh && sh /tmp/rustup.sh -y
ENV PATH="/root/.cargo/bin:$PATH"
WORKDIR /opt/indexer
# Copy root files
COPY package.json .
COPY yarn.lock .
COPY tsconfig.json .
COPY lerna.json .
# Copy shared and package files
COPY packages/indexer-common/ ./packages/indexer-common
COPY packages/indexer-agent/ ./packages/indexer-agent
# Install dependencies; include dev dependencies
RUN yarn --frozen-lockfile --non-interactive --production=false
########################################################################
# Runtime image
FROM node:20.11-bookworm-slim
ENV NODE_ENV production
# When simulating large transactions, sometimes indexer-agent runs out of memory.
# This flag seems force node into GC earlier, preventing the crash
# 1536mb is 1.5GB, which is appropriate for an environment with 2GB RAM
# todo: increase this temporarily to 4GB to see if it fixes the crash
ENV NODE_OPTIONS="--max-old-space-size=4096"
RUN apt-get update && apt-get install -y python3 build-essential git curl
# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rustup.sh && sh /tmp/rustup.sh -y
ENV PATH="/root/.cargo/bin:$PATH"
WORKDIR /opt/indexer
# Copy root files
COPY package.json .
COPY yarn.lock .
COPY tsconfig.json .
COPY lerna.json .
# Copy build output
COPY --from=build /opt/indexer/packages/indexer-common/package.json /opt/indexer/packages/indexer-common/package.json
COPY --from=build /opt/indexer/packages/indexer-common/dist /opt/indexer/packages/indexer-common/dist
COPY --from=build /opt/indexer/packages/indexer-agent/package.json /opt/indexer/packages/indexer-agent/package.json
COPY --from=build /opt/indexer/packages/indexer-agent/dist /opt/indexer/packages/indexer-agent/dist
# Install dependencies; exclude dev dependencies
RUN yarn --frozen-lockfile --non-interactive
ENV ETHEREUM ""
# Run the indexer-agent
WORKDIR /opt/indexer/packages/indexer-agent
ENTRYPOINT ["node", "dist/index.js", "start"]