diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..dee1992 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +__pycache__ +.pytest_cache +.venv +.git +*.pyc +*.pyo +*.pyd +*.swp +*.swo diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8d057e5 --- /dev/null +++ b/Makefile @@ -0,0 +1,27 @@ +COMPOSE = docker compose + +.PHONY: init up test down help +.DEFAULT_GOAL := help + +# 初回セットアップまたは依存関係の更新時に実行 +init: + $(COMPOSE) build + +# コンテナ起動 +up: + $(COMPOSE) up -d + +# テスト実行 +test: + $(COMPOSE) run --rm app + +# 後片付け +down: + $(COMPOSE) down + +# 使い方表示 +help: + @echo "make init - ビルド(初回セットアップ)" + @echo "make up - コンテナ起動(バックグラウンド)" + @echo "make test - テスト実行(pytest)" + @echo "make down - コンテナ停止と後片付け" diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..161ae26 --- /dev/null +++ b/compose.yml @@ -0,0 +1,9 @@ +services: + app: + build: + context: . + dockerfile: docker/app/Dockerfile + working_dir: /app + volumes: + - .:/app + command: ["pytest", "-vv"] diff --git a/docker/app/Dockerfile b/docker/app/Dockerfile new file mode 100644 index 0000000..bd760c0 --- /dev/null +++ b/docker/app/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3.11-slim + +WORKDIR /app + +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONUNBUFFERED=1 + +COPY requirements.txt /app/requirements.txt +RUN pip install --no-cache-dir -r requirements.txt + +COPY src /app/src +COPY test /app/test +COPY README.md /app/README.md