maestro/Dockerfile
oss-sync 42031b18b0
Some checks failed
CI / build-and-test (push) Has been cancelled
sync: update from private repo (8447335)
2026-06-05 06:25:26 +00:00

78 lines
2.3 KiB
Docker

FROM node:22-alpine AS builder
WORKDIR /app
# build:server runs `bash scripts/generate-version.sh` (set -o pipefail), and
# the alpine base ships only ash/sh — without bash the build fails with
# "bash: not found" (exit 127). The runtime stage installs bash separately.
RUN apk add --no-cache bash
COPY package.json package-lock.json* ./
COPY ui/package.json ui/package-lock.json* ./ui/
RUN npm ci --ignore-scripts
RUN npm --prefix ui ci --ignore-scripts
# noVNC スタンドアロン (vnc.html を含む Web 配布物) を取得。
# npm の @novnc/novnc は lib のみで vnc.html を含まないため、
# Browser タブの iframe 用に GitHub から tarball を取得する。
ARG NOVNC_VERSION=1.6.0
RUN apk add --no-cache --virtual .novnc-fetch curl tar \
&& mkdir -p /app/vendor/noVNC \
&& curl -fSL "https://github.com/novnc/noVNC/archive/refs/tags/v${NOVNC_VERSION}.tar.gz" \
| tar -xz -C /app/vendor/noVNC --strip-components=1 \
&& test -f /app/vendor/noVNC/vnc.html \
&& apk del .novnc-fetch
COPY tsconfig.json ./
COPY src ./src
COPY ui ./ui
RUN npm run build:server
RUN npm run build:ui
FROM node:22-alpine AS runtime
RUN apk add --no-cache \
git \
ca-certificates \
tzdata \
bash \
bubblewrap \
python3 \
py3-pip \
&& apk add --no-cache --virtual .native-build-deps build-base
# Pre-bake python packages into the system site-packages (read-only bind-mounted
# into every bash sandbox). Runtime `pip install` is intentionally unsupported.
COPY runtime/python-requirements.txt /tmp/python-requirements.txt
RUN pip3 install --no-cache-dir --break-system-packages -r /tmp/python-requirements.txt \
&& rm /tmp/python-requirements.txt
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm ci --omit=dev \
&& npm cache clean --force \
&& apk del .native-build-deps
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/ui/dist ./ui/dist
COPY --from=builder /app/vendor ./vendor
COPY pieces ./pieces
COPY docs ./docs
# Ship a runnable default while still allowing a read-only config mount.
COPY config.yaml.example ./config.yaml
RUN mkdir -p /data /workspaces \
&& chown -R node:node /data /workspaces
ENV NODE_ENV=production \
PORT=9876 \
DB_PATH=/data/maestro.db
EXPOSE 9876
USER node
CMD ["node", "dist/main.js"]