Init project
This commit is contained in:
28
Dockerfile
Normal file
28
Dockerfile
Normal file
@@ -0,0 +1,28 @@
|
||||
FROM python:3.11-slim
|
||||
|
||||
# 作業ディレクトリを設定
|
||||
WORKDIR /app
|
||||
|
||||
# システムパッケージを更新
|
||||
RUN apt-get update && apt-get install -y \
|
||||
ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Pythonの依存関係をコピーしてインストール
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# アプリケーションファイルをコピー
|
||||
COPY app.py .
|
||||
|
||||
# 非rootユーザーを作成
|
||||
RUN useradd --create-home --shell /bin/bash appuser
|
||||
RUN chown -R appuser:appuser /app
|
||||
USER appuser
|
||||
|
||||
# ヘルスチェックを追加
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD python -c "import sys; sys.exit(0)"
|
||||
|
||||
# アプリケーションを実行
|
||||
CMD ["python", "app.py"]
|
||||
Reference in New Issue
Block a user