Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
47 lines (35 loc) · 1.6 KB
/
Copy pathDockerfile
File metadata and controls
47 lines (35 loc) · 1.6 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
# syntax=docker/dockerfile:1
# Runs AI Code Zero in your browser from a container: the same app as the desktop
# version, served by server.js. See docs/self-hosting/docker.mdx.
# ---- Build stage -----------------------------------------------------------
FROM node:22-alpine AS builder
WORKDIR /app
# Electron is only needed for the desktop app; skip its ~100 MB download.
ENV ELECTRON_SKIP_BINARY_DOWNLOAD=1
COPY package.json package-lock.json ./
# package.json overrides minimatch and onnxruntime-node with these local folders (see their READMEs).
COPY vendor/minimatch-compat vendor/minimatch-compat
COPY vendor/onnxruntime-node-stub vendor/onnxruntime-node-stub
RUN npm ci
COPY . .
RUN npm run build && npm run build:server
# ---- Runtime stage ---------------------------------------------------------
# The server is bundled into one file with its dependencies, so the runtime
# image needs no node_modules.
FROM node:22-alpine AS runtime
WORKDIR /app
ENV NODE_ENV=production \
PORT=3000 \
HOST=0.0.0.0 \
AICODEZERO_DATA_DIR=/data
# Saved keys now live in each visitor's browser, not here. Older versions kept
# them in this folder, and server.mjs deletes those files at startup, so it
# stays writable for the node user (docker-compose.yml's volume takes its owner).
RUN mkdir -p /data && chown node:node /data && chmod 700 /data
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/dist-server/server.mjs ./server.mjs
USER node
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget -q -O /dev/null http://127.0.0.1:3000/ || exit 1
CMD ["node", "server.mjs"]