-
Notifications
You must be signed in to change notification settings - Fork 2k
Feat/localization tests docker #371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 17 commits
0bc7a91
ce188fe
c62586b
b25df1e
b81d709
7caee6c
88d5bc0
aa2f7ad
e1145e8
d7753e4
9e91bb9
d3c71b8
154856c
f8dcf3e
0c4bf20
47a0a65
300aef2
93146c7
03e4b5e
b2b4736
3fd5802
2e70253
932a554
c0402ef
57b9735
35f2652
86bce14
2b4b808
5acdc99
cab3fef
95b4a5e
9a2919d
20774a8
e6e703f
9efe82c
8f5468e
ab81f51
5b17532
08e82ee
443fb14
6ab6a0e
0b82e19
bcde123
3d25a3f
9bfa7db
8a49151
c0b1d3d
ba4da23
1dc2dec
210eb8e
b2eabd4
d31845a
bf6aa14
97307ce
0aaf868
eb8a1f6
c7477bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,51 +1,35 @@ | ||
| # Build stage | ||
| FROM python:3.12-slim-bookworm AS builder | ||
|
|
||
| # Install uv using the official method | ||
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ | ||
| # Stage 1: Frontend Builder | ||
| FROM oven/bun:1-slim AS frontend-builder | ||
| WORKDIR /app/frontend | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Prompt for AI agents |
||
| # Install system dependencies required for building certain Python packages | ||
| # Add Node.js 20.x LTS for building frontend | ||
| RUN apt-get update && apt-get upgrade -y && apt-get install -y \ | ||
| gcc g++ git make \ | ||
| curl \ | ||
| && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ | ||
| && apt-get install -y nodejs \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
| # Copy dependency files first to leverage cache | ||
| COPY frontend/package.json frontend/bun.lock ./ | ||
| RUN bun install --frozen-lockfile | ||
|
|
||
| # Set build optimization environment variables | ||
| ENV MAKEFLAGS="-j$(nproc)" | ||
| ENV PYTHONDONTWRITEBYTECODE=1 | ||
| ENV PYTHONUNBUFFERED=1 | ||
| ENV UV_COMPILE_BYTECODE=1 | ||
| ENV UV_LINK_MODE=copy | ||
| # Copy the rest of the frontend source | ||
| COPY frontend/ ./ | ||
| # Build the frontend | ||
| RUN bun run build | ||
|
|
||
| # Set the working directory in the container to /app | ||
| # Stage 2: Backend Builder | ||
| FROM python:3.12-slim-bookworm AS backend-builder | ||
| # Install uv | ||
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ | ||
| WORKDIR /app | ||
|
|
||
| # Copy dependency files and minimal package structure first for better layer caching | ||
| # 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 with optimizations (this layer will be cached unless dependencies change) | ||
| # Install dependencies | ||
| RUN uv sync --frozen --no-dev | ||
|
|
||
| # Copy the rest of the application code | ||
| COPY . /app | ||
|
|
||
| # Install frontend dependencies and build | ||
| WORKDIR /app/frontend | ||
| RUN npm ci | ||
| RUN npm run build | ||
|
|
||
| # Return to app root | ||
| WORKDIR /app | ||
|
|
||
| # Runtime stage | ||
| # Stage 3: Runtime | ||
| FROM python:3.12-slim-bookworm AS runtime | ||
|
|
||
| # Install only runtime system dependencies (no build tools) | ||
| # Add Node.js 20.x LTS for running frontend | ||
| # Install runtime dependencies | ||
| RUN apt-get update && apt-get upgrade -y && apt-get install -y \ | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am concerned that removing upgrade could expose the app to vulnerability. Why did you propose this? Any special reason? |
||
| ffmpeg \ | ||
| supervisor \ | ||
|
|
@@ -57,27 +41,22 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y \ | |
| # Install uv using the official method | ||
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ | ||
|
|
||
| # Set the working directory in the container to /app | ||
| WORKDIR /app | ||
|
|
||
| # Copy the virtual environment from builder stage | ||
| COPY --from=builder /app/.venv /app/.venv | ||
|
|
||
| # Copy the application code | ||
| COPY --from=builder /app /app | ||
| # Copy backend virtualenv | ||
| COPY --from=backend-builder /app/.venv /app/.venv | ||
| # Copy application code | ||
| COPY . /app/ | ||
|
|
||
| # Copy built frontend from builder stage | ||
| COPY --from=builder /app/frontend/.next/standalone /app/frontend/ | ||
| COPY --from=builder /app/frontend/.next/static /app/frontend/.next/static | ||
| COPY --from=builder /app/frontend/public /app/frontend/public | ||
|
|
||
| # Expose ports for Frontend and API | ||
| EXPOSE 8502 5055 | ||
| # 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 | ||
|
|
||
| # Setup directories and permissions | ||
| RUN mkdir -p /app/data | ||
|
|
||
| # Copy and make executable the wait-for-api script | ||
| COPY scripts/wait-for-api.sh /app/scripts/wait-for-api.sh | ||
| # Ensure wait-for-api script is executable | ||
| RUN chmod +x /app/scripts/wait-for-api.sh | ||
|
|
||
| # Copy supervisord configuration | ||
|
|
@@ -86,14 +65,8 @@ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf | |
| # Create log directories | ||
| RUN mkdir -p /var/log/supervisor | ||
|
|
||
| # Runtime API URL Configuration | ||
| # The API_URL environment variable can be set at container runtime to configure | ||
| # where the frontend should connect to the API. This allows the same Docker image | ||
| # to work in different deployment scenarios without rebuilding. | ||
| # | ||
| # If not set, the system will auto-detect based on incoming requests. | ||
| # Set API_URL when using reverse proxies or custom domains. | ||
| # | ||
| # Example: docker run -e API_URL=https://your-domain.com/api ... | ||
| # Expose ports | ||
| EXPOSE 8502 5055 | ||
|
|
||
| # Set startup command | ||
| CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] | ||
Uh oh!
There was an error while loading. Please reload this page.