-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile-gpu
More file actions
120 lines (98 loc) · 4.32 KB
/
Copy pathDockerfile-gpu
File metadata and controls
120 lines (98 loc) · 4.32 KB
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
ARG NODE_BUILD_VERSION=24
ARG NODE_VERSION=24
# Runtime base. CUDA 13.x supports Turing (SM 7.5 / T4) — Turing is the minimum
# architecture in the 13.x line (Maxwell/Pascal/Volta were dropped). The 13.x
# runtime requires an R580+ host driver; on hosts pinned to an older driver
# branch, override with a CUDA 12.x cudnn-runtime base, e.g.:
# --build-arg CUDA_RUNTIME_IMAGE=nvidia/cuda:12.6.3-cudnn-runtime-ubuntu24.04
#
# Keep the ubuntu24.04 variant (glibc 2.39) whichever CUDA line you pick. This
# image bundles uWebSockets.js (copied from the build stage below), whose
# prebuilt Linux binaries link against GLIBC_2.38 — ubuntu22.04 ships glibc 2.35
# and the addon fails to load there, the same failure that put the standard
# image on Debian trixie. See the note at the top of ./Dockerfile.
#
# Must stay above the first FROM: an ARG referenced by a FROM has to be declared
# in the global scope, before any stage. Declared after a FROM it belongs to that
# stage, and the later FROM expands it to an empty base name.
ARG CUDA_RUNTIME_IMAGE=nvidia/cuda:13.3.0-cudnn-runtime-ubuntu24.04
FROM docker.io/node:${NODE_BUILD_VERSION} AS build
WORKDIR /usr/src/harper-pro
COPY . .
RUN env NO_USE_GIT=true npm run package
FROM ${CUDA_RUNTIME_IMAGE} AS run
ARG NODE_VERSION=24
# Required by NVIDIA Container Runtime to expose GPUs to the container
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
USER root
# Install Node.js via NodeSource plus required utilities
RUN <<-EOF
set -e
apt-get update
apt-get install -y --no-install-recommends ca-certificates curl git gnupg libatomic1 wget zstd
mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \
| gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR="$(echo "$NODE_VERSION" | cut -d. -f1)"
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main" \
| tee /etc/apt/sources.list.d/nodesource.list
apt-get update
apt-get install -y nodejs
# harperdb must own uid/gid 1000 — existing deployments' data volumes are
# chowned to it — so reclaim the id from any incumbent rather than moving
# harperdb. Ubuntu 24.04 bases ship a default `ubuntu` user at 1000; 22.04
# bases ship none, and CUDA_RUNTIME_IMAGE is overridable, so handle both.
# Renaming (as ./Dockerfile does for node:*'s `node` user) keeps the id stable.
EXISTING_USER="$(getent passwd 1000 | cut -d: -f1)" || true
if [ -n "$EXISTING_USER" ]; then
EXISTING_GROUP="$(getent group 1000 | cut -d: -f1)" || true
usermod -d /home/harperdb -l harperdb "$EXISTING_USER"
if [ -n "$EXISTING_GROUP" ]; then
groupmod -n harperdb "$EXISTING_GROUP"
fi
rm -rf "/home/$EXISTING_USER"
else
groupadd --gid 1000 harperdb
useradd --uid 1000 --gid 1000 --home-dir /home/harperdb --shell /bin/bash --no-create-home harperdb
fi
mkdir -p /home/harperdb
chown harperdb:harperdb /home/harperdb
rm -rf /var/lib/apt/lists/*
EOF
WORKDIR /home/harperdb
USER harperdb
# Install pnpm
RUN wget -qO- https://get.pnpm.io/install.sh | ENV="$HOME/.bashrc" SHELL="$(which bash)" bash -
COPY --from=build /usr/src/harper-pro/harperfast-harper-pro-*.tgz .
# Configure NPM
ENV NPM_CONFIG_PREFIX=/home/harperdb/.npm-global
ENV PATH=/home/harperdb/.npm-global/bin:$PATH
# Install Harper Pro globally. See Dockerfile for why `set -e` and the assertion
# are load-bearing here.
RUN <<-EOF
set -e
npm install --global harperfast-harper-pro-*.tgz
harper version
rm harperfast-harper-pro-*.tgz
mkdir -p /home/harperdb/harper
chown harperdb:harperdb /home/harperdb/harper
EOF
# uWS is opt-in for npm consumers but remains bundled in official images.
COPY --from=build --chown=harperdb:harperdb /usr/src/harper-pro/node_modules/uWebSockets.js /home/harperdb/.npm-global/lib/node_modules/@harperfast/harper-pro/node_modules/uWebSockets.js/
VOLUME /home/harperdb/harper
# Harper config parameters
ENV HDB_ADMIN_USERNAME=admin
ENV HDB_ADMIN_PASSWORD=password
ENV ROOTPATH=/home/harperdb/harper
ENV TC_AGREEMENT=yes
ENV OPERATIONSAPI_NETWORK_PORT=9925
ENV LOGGING_STDSTREAMS=true
ENV NODE_HOSTNAME=localhost
ENV DEFAULTS_MODE=prod
EXPOSE 9925
EXPOSE 9926
EXPOSE 9932
EXPOSE 9933
ENTRYPOINT ["harper"]
CMD ["run"]