rein0421 commited on
Commit
6b563fb
·
verified ·
1 Parent(s): a5dea16

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -12
Dockerfile CHANGED
@@ -1,32 +1,32 @@
1
- # Use the official Python 3.10.9 image
2
  FROM python:3.10.9
3
 
4
- # Set the working directory to /app
5
  WORKDIR /app
6
 
7
- # Copy the current directory contents into /app inside the container
8
  COPY . .
9
 
10
- # Install dependencies for OpenCV and other requirements
11
  RUN apt-get update && apt-get install -y libgl1 libglib2.0-0 curl
12
 
13
- # Create a user to avoid permission issues
14
  RUN useradd -m appuser
15
 
16
- # Ensure that saved_images directory is created and has the right permissions
17
- RUN mkdir -p /app/saved_images && chown -R appuser:appuser /app/saved_images
18
 
19
- # Switch to the non-root user
20
  USER appuser
21
 
22
- # Add /home/appuser/.local/bin to PATH
23
  ENV PATH="/home/appuser/.local/bin:${PATH}"
24
 
25
- # Install Python dependencies
26
  RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
27
 
28
- # Set the FastAPI app environment variable to point to the app file path
29
  ENV PYTHONPATH=/app
30
 
31
- # Start the FastAPI app
32
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Python 3.10.9の公式イメージを使用
2
  FROM python:3.10.9
3
 
4
+ # 作業ディレクトリを /app に設定
5
  WORKDIR /app
6
 
7
+ # 現在のディレクトリの内容をコンテナ内の /app にコピー
8
  COPY . .
9
 
10
+ # OpenCVやその他の依存関係をインストール
11
  RUN apt-get update && apt-get install -y libgl1 libglib2.0-0 curl
12
 
13
+ # パーミッションの問題を避けるため、ユーザーを作成
14
  RUN useradd -m appuser
15
 
16
+ # `saved_images`ディレクトリを作成し、`appuser`に書き込み権限を付与
17
+ RUN mkdir -p /app/saved_images && chown -R appuser:appuser /app /app/saved_images
18
 
19
+ # rootユーザーに切り替え
20
  USER appuser
21
 
22
+ # /home/appuser/.local/bin PATH に追加
23
  ENV PATH="/home/appuser/.local/bin:${PATH}"
24
 
25
+ # Pythonの依存関係をインストール
26
  RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
27
 
28
+ # FastAPIアプリの環境変数を設定
29
  ENV PYTHONPATH=/app
30
 
31
+ # FastAPIアプリの起動
32
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]