Skip to content

Commit 33ad884

Browse files
committed
Merge remote-tracking branch 'origin/main' into feature/persistentStorage
2 parents 97c754e + 6a3e228 commit 33ad884

15 files changed

Lines changed: 232 additions & 136 deletions

File tree

.dockerignore

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,17 @@ node_modules
22
/dist
33
logs
44
c2d_storage
5-
.env.local
6-
.env
5+
databases
6+
.env
7+
.env.*
8+
.git
9+
.github
10+
docs
11+
src/test
12+
*.md
13+
*.log
14+
.nyc_output
15+
coverage
16+
docker-compose.yml
17+
elasticsearch-compose.yml
18+
typesense-compose.yml

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @alexcos20 @bogdanfazakas @giurgiur99 @denisiuriet @ndrpp @andreip136
1+
* @alexcos20 @bogdanfazakas @giurgiur99 @dnsi0 @ndrpp @andreip136

Dockerfile

Lines changed: 50 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,53 @@
1-
FROM ubuntu:22.04 AS base
2-
RUN apt-get update && apt-get -y install bash curl git wget libatomic1 python3 build-essential
3-
COPY .nvmrc /usr/src/app/
4-
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
5-
ENV NVM_DIR=/usr/local/nvm
6-
RUN mkdir $NVM_DIR
7-
ENV NODE_VERSION=v22.15.0
8-
# Install nvm with node and npm
9-
RUN curl https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \
10-
&& source $NVM_DIR/nvm.sh \
11-
&& nvm install $NODE_VERSION \
12-
&& nvm alias default $NODE_VERSION \
13-
&& nvm use default
14-
ENV NODE_PATH=$NVM_DIR/$NODE_VERSION/lib/node_modules
15-
ENV PATH=$NVM_DIR/versions/node/$NODE_VERSION/bin:$PATH
16-
ENV IPFS_GATEWAY='https://ipfs.io/'
17-
ENV ARWEAVE_GATEWAY='https://arweave.net/'
18-
19-
FROM base AS builder
20-
COPY package*.json /usr/src/app/
21-
COPY scripts/ /usr/src/app/scripts/
22-
WORKDIR /usr/src/app/
1+
FROM node:22.15.0-bookworm@sha256:a1f1274dadd49738bcd4cf552af43354bb781a7e9e3bc984cfeedc55aba2ddd8 AS builder
2+
RUN apt-get update && apt-get install -y --no-install-recommends \
3+
python3 \
4+
build-essential \
5+
libatomic1 \
6+
git \
7+
&& rm -rf /var/lib/apt/lists/*
8+
9+
WORKDIR /usr/src/app
10+
COPY package*.json ./
11+
COPY scripts/ ./scripts/
2312
RUN npm ci
13+
COPY . .
14+
RUN npm run build && npm prune --omit=dev
15+
16+
17+
FROM node:22.15.0-bookworm-slim@sha256:557e52a0fcb928ee113df7e1fb5d4f60c1341dbda53f55e3d815ca10807efdce AS runner
18+
RUN apt-get update && apt-get install -y --no-install-recommends \
19+
dumb-init \
20+
gosu \
21+
libatomic1 \
22+
&& rm -rf /var/lib/apt/lists/*
23+
24+
ENV NODE_ENV=production \
25+
IPFS_GATEWAY='https://ipfs.io/' \
26+
ARWEAVE_GATEWAY='https://arweave.net/' \
27+
P2P_ipV4BindTcpPort=9000 \
28+
P2P_ipV4BindWsPort=9001 \
29+
P2P_ipV6BindTcpPort=9002 \
30+
P2P_ipV6BindWsPort=9003 \
31+
P2P_ipV4BindWssPort=9005 \
32+
HTTP_API_PORT=8000
33+
34+
EXPOSE 9000 9001 9002 9003 9005 8000
35+
36+
# Docker group membership is handled at runtime in docker-entrypoint.sh by
37+
# inspecting the GID of /var/run/docker.sock, so it works across hosts.
38+
39+
WORKDIR /usr/src/app
40+
41+
COPY --chown=node:node --from=builder /usr/src/app/dist ./dist
42+
COPY --chown=node:node --from=builder /usr/src/app/node_modules ./node_modules
43+
COPY --chown=node:node --from=builder /usr/src/app/schemas ./schemas
44+
COPY --chown=node:node --from=builder /usr/src/app/package.json ./
45+
COPY --chown=node:node --from=builder /usr/src/app/config.json ./
46+
47+
RUN mkdir -p databases c2d_storage logs
2448

49+
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
50+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
2551

26-
FROM base AS runner
27-
COPY . /usr/src/app
28-
WORKDIR /usr/src/app/
29-
COPY --from=builder /usr/src/app/node_modules/ /usr/src/app/node_modules/
30-
RUN npm run build
31-
ENV P2P_ipV4BindTcpPort=9000
32-
EXPOSE 9000
33-
ENV P2P_ipV4BindWsPort=9001
34-
EXPOSE 9001
35-
ENV P2P_ipV6BindTcpPort=9002
36-
EXPOSE 9002
37-
ENV P2P_ipV6BindWsPort=9003
38-
EXPOSE 9003
39-
ENV P2P_ipV4BindWssPort=9005
40-
EXPOSE 9005
41-
ENV HTTP_API_PORT=8000
42-
EXPOSE 8000
43-
ENV NODE_ENV='production'
44-
CMD ["npm","run","start"]
52+
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
53+
CMD ["node", "--max-old-space-size=28784", "--trace-warnings", "--experimental-specifier-resolution=node", "dist/index.js"]

docker-entrypoint.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Fix ownership of directories that may be mounted as volumes (owned by root).
5+
# Runs as root, then drops to 'node' user via gosu.
6+
chown -R node:node /usr/src/app/databases /usr/src/app/c2d_storage /usr/src/app/logs 2>/dev/null || true
7+
8+
# Add node user to the docker group matching the host's /var/run/docker.sock GID,
9+
# so compute jobs can access the socket regardless of the host's docker GID.
10+
if [ -S /var/run/docker.sock ]; then
11+
SOCK_GID=$(stat -c '%g' /var/run/docker.sock)
12+
if ! getent group "$SOCK_GID" > /dev/null 2>&1; then
13+
groupadd -g "$SOCK_GID" dockerhost 2>/dev/null || true
14+
fi
15+
DOCKER_GROUP=$(getent group "$SOCK_GID" | cut -d: -f1)
16+
usermod -aG "$DOCKER_GROUP" node
17+
fi
18+
19+
exec gosu node dumb-init -- "$@"

docs/env.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ The `DOCKER_COMPUTE_ENVIRONMENTS` environment variable should be a JSON array of
137137
{
138138
"socketPath": "/var/run/docker.sock",
139139
"scanImages": true,
140+
"enableNetwork": false,
140141
"imageRetentionDays": 7,
141142
"imageCleanupInterval": 86400,
142143
"resources": [
@@ -195,7 +196,9 @@ The `DOCKER_COMPUTE_ENVIRONMENTS` environment variable should be a JSON array of
195196
#### Configuration Options
196197

197198
- **socketPath**: Path to the Docker socket (e.g., docker.sock).
198-
- **scanImages**: If the docker images should be scan for vulnerabilities using trivy. If yes and critical vulnerabilities are found, then C2D job is refused
199+
- **scanImages**: Whether Docker images should be scanned for vulnerabilities using Trivy. If enabled and critical vulnerabilities are found, the C2D job is rejected.
200+
- **scanImageDBUpdateInterval**: How often to update the vulnerability database, in seconds. Default: 43200 (12 hours)
201+
- **enableNetwork**: Whether networking is enabled for algorithm containers. Default: false
199202
- **imageRetentionDays** - how long docker images are kept, in days. Default: 7
200203
- **imageCleanupInterval** - how often to run cleanup for docker images, in seconds. Min: 3600 (1hour), Default: 86400 (24 hours)
201204
- **paymentClaimInterval** - how often to run payment claiming, in seconds. Default: 3600 (1 hour)

0 commit comments

Comments
 (0)