2026-04-24 23:08:42 -03:00
|
|
|
# ── Stage 1: Next.js build ───────────────────────────────────────────────────
|
|
|
|
|
FROM node:22-alpine AS builder
|
2026-04-23 23:40:34 -03:00
|
|
|
WORKDIR /build
|
2026-04-24 23:08:42 -03:00
|
|
|
|
2026-04-23 23:40:34 -03:00
|
|
|
COPY package.json package-lock.json ./
|
2026-04-25 15:08:25 -03:00
|
|
|
RUN --mount=type=cache,target=/root/.npm \
|
|
|
|
|
npm ci
|
2026-04-24 23:08:42 -03:00
|
|
|
|
2026-04-23 23:40:34 -03:00
|
|
|
COPY src/ ./src/
|
2026-04-25 03:24:20 -03:00
|
|
|
COPY public/ ./public/
|
2026-04-23 23:40:34 -03:00
|
|
|
COPY next.config.ts tsconfig.json postcss.config.mjs ./
|
|
|
|
|
RUN npm run build
|
|
|
|
|
|
2026-04-24 23:08:42 -03:00
|
|
|
# ── Stage 2: runtime ─────────────────────────────────────────────────────────
|
|
|
|
|
FROM debian:bookworm-slim
|
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
|
|
|
|
|
ARG MEDIAMTX_VERSION=1.17.1
|
|
|
|
|
|
2026-04-25 15:08:25 -03:00
|
|
|
# Cache mounts: .deb baixados e índice de pacotes ficam no cache do BuildKit (não entram na imagem)
|
|
|
|
|
# /var/lib/apt/lists: índice apt (apt-get update) — seguro cachear
|
|
|
|
|
# /var/cache/apt: .deb baixados — seguro cachear
|
|
|
|
|
# /var/lib/apt inteiro NÃO é cacheado: extended_states rastreia auto/manual e corromperia o estado entre builds
|
|
|
|
|
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
|
|
|
|
--mount=type=cache,target=/var/lib/apt/lists,sharing=locked \
|
|
|
|
|
apt-get update \
|
2026-04-24 23:08:42 -03:00
|
|
|
&& apt-get install -y --no-install-recommends \
|
|
|
|
|
xvfb x11vnc novnc websockify \
|
|
|
|
|
ffmpeg supervisor xdotool tzdata \
|
|
|
|
|
chromium \
|
|
|
|
|
curl gnupg \
|
|
|
|
|
&& ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \
|
|
|
|
|
\
|
|
|
|
|
# Node.js 22
|
|
|
|
|
&& curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
|
|
|
|
|
&& apt-get install -y --no-install-recommends nodejs \
|
|
|
|
|
\
|
|
|
|
|
# MediaMTX
|
|
|
|
|
&& curl -fsSL "https://github.com/bluenviron/mediamtx/releases/download/v${MEDIAMTX_VERSION}/mediamtx_v${MEDIAMTX_VERSION}_linux_amd64.tar.gz" \
|
|
|
|
|
-o /tmp/mediamtx.tar.gz \
|
|
|
|
|
&& tar -xzf /tmp/mediamtx.tar.gz -C /usr/local/bin mediamtx \
|
|
|
|
|
\
|
2026-04-25 15:08:25 -03:00
|
|
|
# Remove apenas as ferramentas de build — qualquer remoção além disso causa cascata em deps do chromium/novnc
|
2026-04-24 23:08:42 -03:00
|
|
|
&& apt-get remove -y curl gnupg \
|
|
|
|
|
&& apt-get autoremove -y \
|
|
|
|
|
&& apt-get clean \
|
2026-04-25 15:08:25 -03:00
|
|
|
&& find /usr/lib/chromium/locales -name '*.pak' ! -name 'en-US.pak' -delete 2>/dev/null || true \
|
2026-04-25 03:24:20 -03:00
|
|
|
\
|
|
|
|
|
# Chromium managed policy: disable password manager and autofill save prompts
|
|
|
|
|
&& mkdir -p /etc/chromium/policies/managed \
|
|
|
|
|
&& printf '{"PasswordManagerEnabled":false,"AutofillAddressEnabled":false,"AutofillCreditCardEnabled":false}' \
|
|
|
|
|
> /etc/chromium/policies/managed/policy.json \
|
|
|
|
|
\
|
2026-04-24 23:08:42 -03:00
|
|
|
&& rm -rf \
|
|
|
|
|
/var/lib/apt/lists/* \
|
|
|
|
|
/tmp/* /var/tmp/* \
|
|
|
|
|
/usr/share/doc \
|
|
|
|
|
/usr/share/man \
|
|
|
|
|
/usr/share/locale \
|
|
|
|
|
/usr/lib/locale
|
|
|
|
|
|
|
|
|
|
COPY --from=builder /build/.next/standalone/ /app/
|
|
|
|
|
COPY --from=builder /build/.next/static/ /app/.next/static/
|
2026-04-25 03:24:20 -03:00
|
|
|
COPY --from=builder /build/public/ /app/public/
|
2026-04-23 23:40:34 -03:00
|
|
|
|
|
|
|
|
COPY config/supervisord.conf /etc/supervisor/supervisord.conf
|
|
|
|
|
COPY config/mediamtx.yml /etc/mediamtx.yml
|
|
|
|
|
COPY scripts/ /opt/scripts/
|
|
|
|
|
COPY docker/entrypoint.sh /entrypoint.sh
|
2026-04-24 23:08:42 -03:00
|
|
|
RUN chmod +x /opt/scripts/*.sh /entrypoint.sh
|
2026-04-23 23:40:34 -03:00
|
|
|
|
|
|
|
|
VOLUME ["/app/data"]
|
2026-04-24 23:08:42 -03:00
|
|
|
EXPOSE 3000 1935 8888 6080
|
2026-04-23 23:40:34 -03:00
|
|
|
|
2026-04-24 23:08:42 -03:00
|
|
|
CMD ["/entrypoint.sh"]
|