Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Docker Build & Push (hummingbot-mcp)

on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- main

jobs:
docker-build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Determine Docker tag
id: vars
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
echo "TAG=latest" >> $GITHUB_ENV
else
echo "TAG=development" >> $GITHUB_ENV
fi

- name: Build and push Docker image (multi-arch)
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: hummingbot/hummingbot-mcp:${{ env.TAG }}
59 changes: 25 additions & 34 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,39 +1,30 @@
# Use a Python image with uv pre-installed
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS uv

# Install the project into `/app`
# Stage 1: Dependencies
FROM python:3.12-slim AS deps
WORKDIR /app
RUN apt-get update && apt-get install -y git && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
pip install uv
COPY pyproject.toml uv.lock ./
RUN uv venv && uv pip install .

# Stage 2: Runtime
FROM python:3.12-slim
WORKDIR /app
RUN apt-get update && apt-get install -y git && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
pip install uv

# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1

# Copy from the cache instead of linking since it's a mounted volume
ENV UV_LINK_MODE=copy

# Install the project's dependencies using the lockfile and settings
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project --no-dev --no-editable

# Then, add the rest of the project source code and install it
# Installing separately from its dependencies allows optimal layer caching
ADD . /app
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev --no-editable

FROM python:3.12-slim-bookworm

# Install system dependencies if needed
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
# Copy the virtual environment from the deps stage
COPY --from=deps /app/.venv /app/.venv

WORKDIR /app

COPY --from=uv /root/.local /root/.local
COPY --from=uv --chown=app:app /app/.venv /app/.venv
# Copy source code
COPY hummingbot_mcp/ ./hummingbot_mcp/
COPY README.md ./
COPY main.py ./
COPY pyproject.toml ./

# Place executables in the environment at the front of the path
ENV PATH="/app/.venv/bin:$PATH"
# Set environment variable to indicate we're running in Docker
ENV DOCKER_CONTAINER=true

# The entrypoint should be the mcp-hummingbot command from pyproject.toml scripts
ENTRYPOINT ["mcp-hummingbot"]
# Run the MCP server using the pre-built venv
ENTRYPOINT ["/app/.venv/bin/python", "main.py"]
Loading