-
Notifications
You must be signed in to change notification settings - Fork 51
feat: add Docker examples and setup documentation #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lemonte
wants to merge
10
commits into
Universal-Commerce-Protocol:main
Choose a base branch
from
lemonte:feat/add-docker-examples
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ff07d06
feat: add Docker examples and setup documentation
lemonte b2c29f6
Merge branch 'main' into feat/add-docker-examples
lemonte 5d0c5bf
feat: add Docker configurations for Node.js and Python servers
lemonte 6d5731c
chore: update .dockerignore to exclude markdown files
lemonte 0bb19b8
fix: update Docker Compose configurations for Node.js and Python servers
lemonte 70d651a
refactor: reorganize Docker Compose files and update documentation
lemonte 57554d9
Merge branch 'main' into feat/add-docker-examples
lemonte 1d68e23
Merge branch 'main' into feat/add-docker-examples
lemonte e21b124
Merge branch 'main' into feat/add-docker-examples
lemonte a79f584
Merge branch 'main' into feat/add-docker-examples
lemonte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lemonte marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| <!-- | ||
| Copyright 2026 UCP Authors | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| --> | ||
|
|
||
| # UCP Docker Examples | ||
|
|
||
| This directory contains Docker configurations for running UCP reference | ||
| implementations. Docker provides a quick and consistent way to run the UCP servers | ||
| without needing to install Node.js, Python, or their dependencies locally. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| * [Docker](https://www.docker.com/get-started) (version 20.10 or higher) | ||
| * [Docker Compose](https://docs.docker.com/compose/install/) (version 2.0 or | ||
| higher) | ||
|
|
||
| ## Available Services | ||
|
|
||
| This directory provides two Docker Compose configurations: | ||
|
|
||
| * **`nodejs/docker-compose.yml`** - Runs the Node.js server | ||
| * **`python/docker-compose.yml`** - Runs the Python server | ||
|
|
||
| For detailed instructions on how to use each service, please refer to their respective documentation: | ||
|
|
||
| * [Node.js Docker Setup](./nodejs/README.md) | ||
| * [Python Docker Setup](./python/README.md) | ||
|
|
||
| ## Additional Resources | ||
|
|
||
| * [Node.js Server Documentation](../rest/nodejs/README.md) | ||
| * [Python Server Documentation](../rest/python/server/README.md) | ||
| * [UCP Documentation](https://ucp.dev) |
lemonte marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| node_modules | ||
| dist | ||
| databases/*.db | ||
| *.log | ||
| .DS_Store | ||
| .env | ||
| .git | ||
| .gitignore | ||
| *.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # Copyright 2026 UCP Authors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| FROM node:20-alpine | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Copy package files | ||
| COPY package*.json ./ | ||
|
|
||
| # Install dependencies | ||
| RUN npm install | ||
|
|
||
| # Copy source files | ||
| COPY tsconfig.json ./ | ||
| COPY src ./src | ||
| COPY scripts ./scripts | ||
|
|
||
| # Create databases directory | ||
| RUN mkdir -p databases | ||
|
|
||
| # Expose port | ||
| EXPOSE 3000 | ||
|
|
||
| # Start server using tsx (runs TypeScript directly, no build step needed) | ||
| CMD ["npx", "tsx", "src/index.ts"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| <!-- | ||
| Copyright 2026 UCP Authors | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| --> | ||
|
|
||
| # Node.js Server Docker Setup | ||
|
|
||
| This directory contains the Docker configuration for running the UCP Node.js server. | ||
|
|
||
| ## Quick Start | ||
|
|
||
| To run the Node.js server: | ||
|
|
||
| ```bash | ||
| cd samples/docker/nodejs | ||
| docker-compose up | ||
| ``` | ||
|
|
||
| The Node.js server will be available at `http://localhost:3000`. | ||
|
|
||
| ## Building the Image | ||
|
|
||
| To build the image without starting the container: | ||
|
|
||
| ```bash | ||
| docker-compose build | ||
| ``` | ||
|
|
||
| To rebuild from scratch (no cache): | ||
|
|
||
| ```bash | ||
| docker-compose build --no-cache | ||
| ``` | ||
|
|
||
| ## Accessing the Service | ||
|
|
||
| Once the service is running, you can access it at `http://localhost:3000`. | ||
|
|
||
| For detailed information on how to test and interact with the server, please refer to the [Node.js Server README](../../rest/nodejs/README.md). | ||
|
|
||
| ## Data Persistence | ||
|
|
||
| The Node.js server uses a Docker volume (`nodejs-databases`) to persist SQLite databases. Data persists across container restarts. | ||
|
|
||
| To remove all data: | ||
|
|
||
| ```bash | ||
| docker-compose down -v | ||
| ``` | ||
|
|
||
| ## Stopping the Service | ||
|
|
||
| To stop the service: | ||
|
|
||
| ```bash | ||
| docker-compose down | ||
| ``` | ||
|
|
||
| To stop and remove volumes (this will delete all data): | ||
|
|
||
| ```bash | ||
| docker-compose down -v | ||
| ``` | ||
|
|
||
| ## Viewing Logs | ||
|
|
||
| To view logs from the service: | ||
|
|
||
| ```bash | ||
| docker-compose logs -f | ||
| ``` | ||
|
|
||
| ## Running in Detached Mode | ||
|
|
||
| To run the service in the background: | ||
|
|
||
| ```bash | ||
| docker-compose up -d | ||
| ``` | ||
|
|
||
| To stop the detached service: | ||
|
|
||
| ```bash | ||
| docker-compose stop | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Port Already in Use | ||
|
|
||
| If port 3000 is already in use, you can change it in `docker-compose.yml`: | ||
|
|
||
| ```yaml | ||
| services: | ||
| nodejs-server: | ||
| ports: | ||
| - "3001:3000" # Change 3001 to your preferred port | ||
| ``` | ||
|
|
||
| ### Build Failures | ||
|
|
||
| If builds fail, try: | ||
|
|
||
| 1. Clean build: `docker-compose build --no-cache` | ||
| 2. Check Docker has enough resources (memory, disk space) | ||
| 3. Ensure you're in the correct directory (`samples/docker/nodejs`) | ||
|
|
||
| ### Container Health Checks | ||
|
|
||
| The service includes health checks. Check status: | ||
|
|
||
| ```bash | ||
| docker-compose ps | ||
| ``` | ||
|
|
||
| ### Orphan Containers and Network Issues | ||
|
|
||
| If you see warnings about orphan containers or network errors: | ||
|
|
||
| 1. Stop all services and remove orphan containers: | ||
| ```bash | ||
| docker-compose down --remove-orphans | ||
| ``` | ||
|
|
||
| 2. If the issue persists, remove the container manually: | ||
| ```bash | ||
| docker rm -f ucp-nodejs-server | ||
| docker-compose up | ||
| ``` | ||
|
|
||
| 3. To clean up all Docker resources (containers, networks, volumes): | ||
| ```bash | ||
| docker-compose down -v --remove-orphans | ||
| ``` | ||
|
|
||
| ## Development | ||
|
|
||
| For development, you may want to mount source code as volumes for live reloading. Modify `docker-compose.yml` to add volume mounts: | ||
|
|
||
| ```yaml | ||
| services: | ||
| nodejs-server: | ||
| volumes: | ||
| - nodejs-databases:/app/databases | ||
| - ../rest/nodejs/src:/app/src # Add for live reload | ||
| ``` | ||
|
|
||
| Note: Live reloading requires additional setup and is not included in the base configuration. |
lemonte marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Copyright 2026 UCP Authors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| services: | ||
| nodejs-server: | ||
| build: | ||
| context: ../../rest/nodejs | ||
| dockerfile: ../../docker/nodejs/Dockerfile | ||
| container_name: ucp-nodejs-server | ||
| ports: | ||
| - "3000:3000" | ||
| volumes: | ||
| - nodejs-databases:/app/databases | ||
| restart: unless-stopped | ||
| healthcheck: | ||
| test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/.well-known/ucp', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"] | ||
| interval: 30s | ||
| timeout: 10s | ||
| retries: 3 | ||
| start_period: 10s | ||
|
|
||
| volumes: | ||
| nodejs-databases: | ||
| driver: local |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| __pycache__ | ||
| *.pyc | ||
| *.pyo | ||
| *.pyd | ||
| .Python | ||
| *.so | ||
| *.egg | ||
| *.egg-info | ||
| dist | ||
| build | ||
| .venv | ||
| venv | ||
| .env | ||
| .git | ||
| .gitignore | ||
| .DS_Store | ||
| *.db | ||
| *.log | ||
| *.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # Copyright 2026 UCP Authors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| FROM python:3.11-slim | ||
|
|
||
| # Install uv | ||
| RUN pip install --no-cache-dir uv | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Copy SDK first (needed by server) | ||
| COPY sdk/python /app/sdk/python | ||
|
|
||
| # Copy server files | ||
| COPY samples/rest/python/server /app/server | ||
|
|
||
| # Copy test data | ||
| COPY samples/rest/python/test_data /app/test_data | ||
|
|
||
| WORKDIR /app/server | ||
|
|
||
| # Update pyproject.toml to use the copied SDK path | ||
| RUN python3 -c "import re; content = open('pyproject.toml').read(); content = re.sub(r'path = \"\.\.\/\.\.\/\.\.\/\.\.\/sdk\/python\/\"', 'path = \"/app/sdk/python/\"', content); open('pyproject.toml', 'w').write(content)" | ||
|
|
||
| # Install dependencies using uv | ||
| RUN uv sync | ||
|
|
||
| # Create data directory for databases | ||
| RUN mkdir -p /app/data | ||
|
|
||
| # Expose port | ||
| EXPOSE 8182 | ||
|
|
||
| # Default command: initialize database and start server | ||
| # Users can override this to run different commands | ||
| CMD ["sh", "-c", "uv run import_csv.py --products_db_path=/app/data/products.db --transactions_db_path=/app/data/transactions.db --data_dir=/app/test_data/flower_shop && uv run server.py --products_db_path=/app/data/products.db --transactions_db_path=/app/data/transactions.db --port=8182"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.