diff --git a/.github/workflows/docker-release.yaml b/.github/workflows/docker-release.yaml index 94bc474..40f1979 100644 --- a/.github/workflows/docker-release.yaml +++ b/.github/workflows/docker-release.yaml @@ -6,10 +6,12 @@ on: jobs: release: runs-on: "ubuntu-latest" - timeout-minutes: 5 + timeout-minutes: 10 steps: - name: Check out the repo uses: actions/checkout@v5 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Log in to Docker Hub uses: docker/login-action@v3 with: @@ -32,6 +34,7 @@ jobs: uses: docker/build-push-action@v6 with: context: . + platforms: linux/amd64,linux/arm64 push: true build-args: | GIT_REVISION=${{ github.sha }} diff --git a/.github/workflows/ghcr-release.yaml b/.github/workflows/ghcr-release.yaml index fa264cf..7d55b80 100644 --- a/.github/workflows/ghcr-release.yaml +++ b/.github/workflows/ghcr-release.yaml @@ -8,12 +8,14 @@ env: jobs: ghcr: runs-on: ubuntu-latest - timeout-minutes: 5 + timeout-minutes: 10 permissions: packages: write contents: read steps: - uses: actions/checkout@v5 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v3 with: registry: ghcr.io @@ -43,5 +45,6 @@ jobs: with: push: true context: . + platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index 44974f7..3384fc8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,4 +37,7 @@ RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt # Copy application code after dependencies are installed COPY . . +# Set PYTHONPATH to include the working directory for module imports +ENV PYTHONPATH="${PYTHONPATH}:/app" + CMD ["python", "template_langgraph/core.py"] diff --git a/Makefile b/Makefile index fbc6224..bd2ae48 100644 --- a/Makefile +++ b/Makefile @@ -76,6 +76,14 @@ docker-build: ## build Docker image docker-run: ## run Docker container docker run --rm $(DOCKER_REPO_NAME)/$(DOCKER_IMAGE_NAME):$(GIT_TAG) $(DOCKER_COMMAND) +.PHONY: docker-run-streamlit +docker-run-streamlit: ## run Docker container with Streamlit app + docker run --rm \ + -p 8501:8501 \ + -v $(PWD)/.env:/app/.env \ + $(DOCKER_REPO_NAME)/$(DOCKER_IMAGE_NAME):$(GIT_TAG) \ + streamlit run template_langgraph/services/streamlits/main.py --server.address 0.0.0.0 + .PHONY: docker-lint docker-lint: ## lint Dockerfile docker run --rm -i hadolint/hadolint < Dockerfile diff --git a/docs/index.ja.md b/docs/index.ja.md index ef19e9a..f4642f9 100644 --- a/docs/index.ja.md +++ b/docs/index.ja.md @@ -240,6 +240,58 @@ Streamlit アプリのデモ: [![streamlit.png](./images/streamlit.png)](https://youtu.be/undxBwyJ3Sc) +### オプション 6: Docker(本番デプロイ) + +アプリケーションを Docker で実行すると、環境差による違いを減らし、一貫したデプロイが可能になります。ここではイメージのビルド、Streamlit のコンテナ実行、事前ビルド済みイメージの利用、マルチアーキテクチャ対応について説明します。 + +#### Docker イメージのビルド + +```shell +# ローカルで Docker イメージをビルド +make docker-build + +# または特定のタグでビルド +docker build -t ks6088ts/template-langgraph:latest . +``` + +#### Streamlit を Docker で実行 + +```shell +# Docker で Streamlit アプリを実行する(Makefile ターゲット) +make docker-run-streamlit + +# または .env をコンテナにマウントして手動で実行 +docker run --rm \ + -p 8501:8501 \ + -v ./.env:/app/.env \ + ks6088ts/template-langgraph:latest \ + streamlit run template_langgraph/services/streamlits/main.py --server.address 0.0.0.0 +``` + +#### 事前ビルド済みイメージの使用 + +```shell +# Docker Hub から実行 +docker run --rm \ + -p 8501:8501 \ + -v ./.env:/app/.env \ + ks6088ts/template-langgraph:latest \ + streamlit run template_langgraph/services/streamlits/main.py --server.address 0.0.0.0 + +# GitHub Container Registry から実行 +docker run --rm \ + -p 8501:8501 \ + -v ./.env:/app/.env \ + ghcr.io/ks6088ts-labs/template-langgraph:latest \ + streamlit run template_langgraph/services/streamlits/main.py --server.address 0.0.0.0 +``` + +#### マルチアーキテクチャ対応 + +このリポジトリの Docker イメージは `amd64` と `arm64` 両アーキテクチャ向けにビルドされています。これにより、Intel/AMD の x64 マシンや Apple Silicon(M1/M2/M3/M4)などの ARM 環境でも動作します。 + +コンテナを起動したら、ブラウザで [http://localhost:8501](http://localhost:8501) にアクセスして Streamlit アプリを確認できます。 + ### 追加の実行例 - Issue formatter(構造化出力): diff --git a/docs/index.md b/docs/index.md index 6dcdae6..cb4f6f0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -240,6 +240,63 @@ Demonstration of the Streamlit app: [![streamlit.png](./images/streamlit.png)](https://youtu.be/undxBwyJ3Sc) +### Option 6: Docker (Production deployment) + +You can run the application in Docker for consistent deployment across environments: + +#### Building the Docker Image + +```shell +# Build the Docker image locally +make docker-build + +# Or build with specific tag +docker build -t ks6088ts/template-langgraph:latest . +``` + +#### Running Streamlit in Docker + +```shell +# Run Streamlit app with Docker +make docker-run-streamlit + +# Or run manually with environment file +docker run --rm \ + -p 8501:8501 \ + -v ./.env:/app/.env \ + ks6088ts/template-langgraph:latest \ + streamlit run template_langgraph/services/streamlits/main.py --server.address 0.0.0.0 +``` + +#### Using Pre-built Images + +You can also use pre-built images from Docker Hub or GitHub Container Registry: + +```shell +# From Docker Hub +docker run --rm \ + -p 8501:8501 \ + -v ./.env:/app/.env \ + ks6088ts/template-langgraph:latest \ + streamlit run template_langgraph/services/streamlits/main.py --server.address 0.0.0.0 + +# From GitHub Container Registry +docker run --rm \ + -p 8501:8501 \ + -v ./.env:/app/.env \ + ghcr.io/ks6088ts-labs/template-langgraph:latest \ + streamlit run template_langgraph/services/streamlits/main.py --server.address 0.0.0.0 +``` + +#### Multi-Architecture Support + +The Docker images are built for both `amd64` and `arm64` architectures, making them compatible with: +- Intel/AMD x64 processors +- Apple Silicon (M1/M2/M3/M4) processors +- ARM-based servers + +Access the Streamlit app at [http://localhost:8501](http://localhost:8501) after running the container. + ### More agent runs - Issue formatter (structured output):