mirror of
https://github.com/lfnovo/open-notebook.git
synced 2026-05-02 21:30:38 +00:00
* chore: force env file on api * fix: Docker networking and permissions documentation - Add HOSTNAME=0.0.0.0 as default in Dockerfiles for reverse proxy compatibility - Document Linux extra_hosts requirement for host.docker.internal - Add user: root to SurrealDB examples for bind mount permissions on Linux - Update environment reference and reverse proxy docs Fixes #483, fixes #485, fixes #409
81 lines
No EOL
2.4 KiB
Text
81 lines
No EOL
2.4 KiB
Text
# Stage 1: Frontend Builder
|
|
FROM node:20-slim AS frontend-builder
|
|
WORKDIR /app/frontend
|
|
|
|
# Copy dependency files first to leverage cache
|
|
COPY frontend/package.json frontend/package-lock.json ./
|
|
ARG NPM_REGISTRY=https://registry.npmjs.org/
|
|
RUN npm config set registry ${NPM_REGISTRY}
|
|
RUN npm ci
|
|
|
|
# Copy the rest of the frontend source
|
|
COPY frontend/ ./
|
|
# Build the frontend
|
|
RUN npm run build
|
|
|
|
# Stage 2: Backend Builder
|
|
FROM python:3.12-slim-bookworm AS backend-builder
|
|
# Install build dependencies
|
|
RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends build-essential && rm -rf /var/lib/apt/lists/*
|
|
# Install uv
|
|
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
|
WORKDIR /app
|
|
|
|
# Set build optimization environment variables
|
|
ENV UV_HTTP_TIMEOUT=120
|
|
|
|
# Copy dependency files first
|
|
COPY pyproject.toml uv.lock ./
|
|
COPY open_notebook/__init__.py ./open_notebook/__init__.py
|
|
# Install dependencies
|
|
RUN uv sync --frozen --no-dev
|
|
|
|
# Stage 3: Runtime
|
|
FROM python:3.12-slim-bookworm AS runtime
|
|
|
|
# Install runtime dependencies
|
|
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
|
|
ffmpeg \
|
|
supervisor \
|
|
curl \
|
|
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
|
&& apt-get install -y nodejs \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install SurrealDB
|
|
RUN curl --proto '=https' --tlsv1.2 -sSf https://install.surrealdb.com | sh
|
|
|
|
# Install uv (optional but helpful for some scripts)
|
|
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy backend virtualenv and source code
|
|
COPY --from=backend-builder /app/.venv /app/.venv
|
|
COPY . /app/
|
|
|
|
# Copy built frontend from standalone output
|
|
COPY --from=frontend-builder /app/frontend/.next/standalone /app/frontend/
|
|
COPY --from=frontend-builder /app/frontend/.next/static /app/frontend/.next/static
|
|
COPY --from=frontend-builder /app/frontend/public /app/frontend/public
|
|
|
|
# Bind Next.js to all interfaces (required for Docker networking and reverse proxies)
|
|
ENV HOSTNAME=0.0.0.0
|
|
|
|
# Setup directories and permissions
|
|
RUN mkdir -p /app/data /mydata
|
|
|
|
# Ensure wait-for-api script is executable
|
|
RUN chmod +x /app/scripts/wait-for-api.sh
|
|
|
|
# Copy supervisord configuration
|
|
COPY supervisord.single.conf /etc/supervisor/conf.d/supervisord.conf
|
|
|
|
# Create log directories
|
|
RUN mkdir -p /var/log/supervisor
|
|
|
|
# Expose ports
|
|
EXPOSE 8502 5055
|
|
|
|
# Set startup command
|
|
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] |