get_mhtml / Dockerfile
ttttdiva's picture
Update Dockerfile
35684ef verified
raw
history blame
1.25 kB
FROM python:3.9
# システム依存ライブラリをインストール
RUN apt-get update && apt-get install -y \
libnss3 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libdrm2 \
libxkbcommon0 \
libwayland-egl1 \
libwayland-cursor0 \
libwayland-server0 \
libgbm1 \
fonts-liberation \
libasound2 \
&& rm -rf /var/lib/apt/lists/*
# 作業ディレクトリ(root権限のまま)
WORKDIR /app
# 依存ライブラリのインストール (Playwright 本体はまだOK)
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
# fastapi, uvicorn, playwright, requests などが入る想定
# 例) requirements.txt:
# fastapi
# uvicorn
# playwright
# requests
# ユーザー作成 & 切り替え
RUN useradd -m -u 1000 user
# 念のため .cache ディレクトリを作って所有権を与える
RUN mkdir -p /home/user/.cache && chown -R user:user /home/user
USER user
# ここで "同じユーザー(user)" としてブラウザをダウンロード
RUN python -m playwright install
# ソースコードをコピー
COPY --chown=user . /app
# 起動コマンド
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]