<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      Stay Hungry,Stay Foolish!

      構建不同環境下的docker鏡像

      同一個dockerfile,支持dev,prod兩套target,對應兩套環境

      https://github.com/fanqingsong/craw4ai-fastapi

      Docker file

      # Dockerfile for crawl4ai-fastapi
      # Using multi-stage build with uv for faster package management
      
      ################################
      # PYTHON-BASE
      # Sets up all our shared environment variables
      ################################
      FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/python:3.11-slim AS python-base
      
          # python
      ENV PYTHONUNBUFFERED=1 \
          # prevents python creating .pyc files
          PYTHONDONTWRITEBYTECODE=1 \
          \
          # pip
          PIP_DISABLE_PIP_VERSION_CHECK=on \
          PIP_DEFAULT_TIMEOUT=100 \
          \
          # uv
          UV_VERSION=0.2.0 \
          # make uv install to this location
          UV_HOME="/opt/uv" \
          # make uv create the virtual environment in the project's root
          # it gets named `.venv`
          UV_VIRTUALENV_IN_PROJECT=true \
          # do not ask any interactive question
          UV_NO_INTERACTION=1 \
          \
          # paths
          # this is where our requirements + virtual environment will live
          PYSETUP_PATH="/opt/pysetup" \
          VENV_PATH="/opt/pysetup/.venv"
      
      # prepend uv and venv to path
      ENV PATH="$UV_HOME/bin:$VENV_PATH/bin:$PATH"
      
      # Update the package list and install necessary libraries
      # 使用清華大學鏡像源加速apt下載
      RUN echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main" > /etc/apt/sources.list && \
          echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian-security/ bookworm-security main" >> /etc/apt/sources.list && \
          echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main" >> /etc/apt/sources.list && \
          apt-get update && apt-get install -y \
          libglib2.0-0 \
          libnss3 \
          libnspr4 \
          libdbus-1-3 \
          libatk1.0-0 \
          libcups2 \
          libcairo2 \
          libpango-1.0-0 \
          libexpat1 \
          libdrm2 \
          libxcb1 \
          libxkbcommon0 \
          libatspi2.0-0 \
          libx11-6 \
          libxcomposite1 \
          libxdamage1 \
          libxrandr2 \
          libxfixes3 \
          libgbm1 \
          libasound2 \
          libatk-bridge2.0-0 \
          && rm -rf /var/lib/apt/lists/*
      
      
      ################################
      # BUILDER-BASE
      # Used to build deps + create our virtual environment
      ################################
      FROM python-base AS builder-base
      # 使用清華大學鏡像源加速apt下載
      RUN echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main" > /etc/apt/sources.list && \
          echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian-security/ bookworm-security main" >> /etc/apt/sources.list && \
          echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main" >> /etc/apt/sources.list && \
          apt-get update \
          && apt-get install --no-install-recommends -y \
              # deps for installing uv
              curl \
              # deps for building python deps
              build-essential
      
      # install uv - 使用國內鏡像源加速安裝
      RUN --mount=type=cache,target=/root/.cache \
          mkdir -p /opt/uv/bin && \
          pip install --no-cache-dir uv && \
          ln -sf $(which uv) /opt/uv/bin/uv && \
          chmod +x /opt/uv/bin/uv && \
          uv --version
      
      # copy project requirement files here to ensure they will be cached.
      WORKDIR $PYSETUP_PATH
      
      # COPY . ./
      COPY requirements.txt ./
      
      # 配置uv使用國內鏡像源并安裝依賴
      RUN --mount=type=cache,target=/root/.cache \
          uv venv && \
          UV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple/ uv pip install -r requirements.txt
      
      ################################
      # DEVELOPMENT
      # Image used during development / testing
      ################################
      FROM python-base AS development
      ENV FASTAPI_ENV=development
      WORKDIR $PYSETUP_PATH
      
      # copy in our built uv + venv
      COPY --from=builder-base $UV_HOME $UV_HOME
      COPY --from=builder-base $PYSETUP_PATH $PYSETUP_PATH
      
      # will become mountpoint of our code
      WORKDIR /app
      
      COPY . .
      
      # 安裝 playwright 和瀏覽器
      RUN python -m playwright install
      
      EXPOSE 8000
      ENV PROCESSOR_NAME=crawler
      
      CMD ["uvicorn", "crawl4ai_fastapi.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
      
      
      ################################
      # PRODUCTION
      # Final image used for runtime
      ################################
      FROM python-base AS production
      ENV FASTAPI_ENV=production
      COPY --from=builder-base $PYSETUP_PATH $PYSETUP_PATH
      
      WORKDIR /app
      
      COPY crawl4ai_fastapi ./crawl4ai_fastapi
      
      # 安裝 playwright 和瀏覽器
      RUN python -m playwright install
      
      CMD ["gunicorn", "-w", "4", "-k", "uvicorn.workers.UvicornWorker", "-b", "0.0.0.0:8000", "crawl4ai_fastapi.main:app"]

       

      docker compose dev yaml

      version: '3.8'
      
      services:
        web:
          build:
            context: .
            target: development
          ports:
            - "8000:8000"
          environment:
            - FASTAPI_ENV=development
            - USER_AGENT=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
            - CRAWLER_TIMEOUT=30
            - REQUEST_TIMEOUT=60
          volumes:
            - .:/app  # 代碼熱重載
          command: ["sh", "-c", "playwright install && uvicorn crawl4ai_fastapi.main:app --host 0.0.0.0 --port 8000 --reload"]

       

      docker compose prod yaml

      version: '3.8'
      
      services:
        web:
          build:
            context: .
            target: production
          ports:
            - "8000:8000"
          environment:
            - FASTAPI_ENV=production
            - USER_AGENT=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
            - CRAWLER_TIMEOUT=30
            - REQUEST_TIMEOUT=60
          command: ["sh", "-c", "playwright install && gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:8000 crawl4ai_fastapi.main:app"]

       

      使用docker。它的環境變量編譯在運行時使用相同的這個環境文件。

      Using --env-filewith Docker Compose

      The --env-fileflag in Docker Compose allows you to specify a file containing environment variables that should be used when running your compose configuration.

      Basic Usage

      docker compose --env-file .env up

      Key Points

      1. ??File Format??: The env file should contain key-value pairs, one per line:

        DB_USER=admin
        DB_PASS=secret
      2. ??Default Behavior??: If you don't specify --env-file, Docker Compose will automatically look for a file named .envin your project directory.

      3. ??Variable Precedence??:

        • Variables specified directly in the command line (-eflag) take highest precedence

        • Then variables from --env-file

        • Finally variables from the default .envfile

      4. ??Compose File Reference??: You can reference these variables in your docker-compose.yml:

        services:
          db:
            environment:
              - POSTGRES_USER=${DB_USER}
              - POSTGRES_PASSWORD=${DB_PASS}

      Example

      1. Create an env file (config.env):

        WEB_PORT=8080
        DB_NAME=mydb
      2. Reference in compose file:

        services:
          web:
            ports:
              - "${WEB_PORT}:80"
          db:
            environment:
              - POSTGRES_DB=${DB_NAME}
      3. Run with:

        docker compose --env-file config.env up

      Notes

      • The env file path is relative to the current working directory

      • Empty lines and lines starting with #are ignored

      • Variable substitution only works in certain fields of the compose file (environment, ports, etc.)


       

      posted @ 2025-08-24 19:26  lightsong  閱讀(21)  評論(0)    收藏  舉報
      千山鳥飛絕,萬徑人蹤滅
      主站蜘蛛池模板: 国产美女MM131爽爽爽| 高潮射精日本韩国在线播放| 九九热精品免费视频| 亚洲欧洲日韩国内精品| 亚洲精品国产自在久久| 国产成人a在线观看视频| 亚洲无人区一码二码三码| 免费无码又爽又刺激网站| 久久亚洲私人国产精品| 欧美牲交a欧美牲交aⅴ免费| 黄色三级亚洲男人的天堂| 日韩精品av一区二区三区| 男女动态无遮挡动态图| 在线观看无码av五月花| 9色国产深夜内射| 日本高清一区二区三| 亚洲国产av久久久| 丁香婷婷色综合激情五月| 亚洲婷婷综合色高清在线| 午夜成人精品福利网站在线观看| 欧美大胆老熟妇乱子伦视频| 九九久久精品国产免费看小说| 张家界市| 精品国产成人亚洲午夜福利| 亚洲国产午夜精品理论片妓女 | 亚洲一区二区三区水蜜桃| 日本亚洲一区二区精品久久| 香蕉EEWW99国产精选免费| 国产欧亚州美日韩综合区| 免费无码午夜福利片| a级黑人大硬长爽猛出猛进| 人人澡人人透人人爽| 免费看女人与善牲交| 丁香五月亚洲综合在线国内自拍| 不卡免费一区二区日韩av| 亚洲自偷自偷在线成人网站传媒| 日韩中文字幕精品人妻| 日本一区三区高清视频| 国产午夜成人无码免费看| 国产日韩一区二区三区在线观看 | 国产精品不卡区一区二|