Skip to content

Commit 0366b8c

Browse files
Merge pull request #7 from imprvhub/6-instructions-for-running-this-in-docker
Co-authored-by: nilsreichardt <[email protected]> Original implementation and GCP deploy process by @nilsreichardt (see referenced commits)
2 parents a182b54 + c37759b commit 0366b8c

File tree

4 files changed

+76
-3
lines changed

4 files changed

+76
-3
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ ENV PATH="/app/.venv/bin:$PATH"
2626
COPY --from=uv /app /app/
2727
ENV PYTHONPATH=/app
2828

29-
ENTRYPOINT ["mcp-domain-availability"]
29+
EXPOSE 8080
30+
31+
ENTRYPOINT ["python", "-m", "mcp_domain_availability.main"]

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,58 @@ uv sync
168168
uv run src/mcp_domain_availability/main.py
169169
```
170170

171+
### Deploying with Docker to Google Cloud Run
172+
173+
You can deploy this service to Google Cloud Run using the provided Dockerfile and deployment script.
174+
175+
**Prerequisites:**
176+
- [Google Cloud SDK](https://cloud.google.com/sdk/docs/install) installed and authenticated (`gcloud auth login`).
177+
- [Docker](https://docs.docker.com/get-docker/) installed and running.
178+
- A Google Cloud Project with the Cloud Run and Container Registry APIs enabled.
179+
180+
#### Using the Deployment Script
181+
182+
The easiest way to deploy is to use the `deploy.sh` script.
183+
184+
1. **Edit the script:**
185+
Open `deploy.sh` and replace `...` with your Google Cloud `PROJECT_ID`. You can also change the `REGION` if needed.
186+
187+
2. **Run the script:**
188+
Make the script executable and run it.
189+
```sh
190+
chmod +x deploy.sh
191+
./deploy.sh
192+
```
193+
The script will build the Docker image, push it to Google Container Registry, and deploy it to Cloud Run.
194+
195+
#### Manual Deployment
196+
197+
Alternatively, you can run the commands manually.
198+
199+
1. **Set environment variables:**
200+
```sh
201+
export PROJECT_ID="<YOUR_PROJECT_ID>"
202+
export REGION="<YOUR_REGION>" # e.g., us-central1
203+
export IMAGE="gcr.io/$PROJECT_ID/mcp-domain-availability:latest"
204+
```
205+
206+
2. **Build and push the Docker image:**
207+
```sh
208+
docker buildx build --platform linux/amd64 -t $IMAGE --push .
209+
```
210+
211+
3. **Deploy to Google Cloud Run:**
212+
```sh
213+
gcloud run deploy mcp-domain-availability \
214+
--image $IMAGE \
215+
--region $REGION \
216+
--platform managed \
217+
--allow-unauthenticated \
218+
--port 8080 \
219+
--project $PROJECT_ID
220+
```
221+
222+
171223
### How It Works
172224

173225
The MCP Domain Availability Checker uses multiple verification methods to determine domain availability:

deploy.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
REGION="europe-west1"
2+
PROJECT_ID="..."
3+
# Need to be exported for sudo to work
4+
export IMAGE="gcr.io/$PROJECT_ID/mcp-domain-availability:latest"
5+
6+
sudo docker buildx build --platform linux/amd64 -t $IMAGE --push .
7+
sudo docker push $IMAGE
8+
9+
gcloud run deploy mcp-domain-availability \
10+
--image $IMAGE \
11+
--region $REGION \
12+
--platform managed \
13+
--allow-unauthenticated \
14+
--port 8080 \
15+
--project $PROJECT_ID

src/mcp_domain_availability/main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import socket
33
import time
44
import re
5+
import os
56
from typing import Dict, List, Tuple, Optional
67
from concurrent.futures import ThreadPoolExecutor
78

@@ -17,7 +18,7 @@
1718

1819
from mcp.server.fastmcp import FastMCP
1920

20-
mcp = FastMCP("Domain Availability Checker")
21+
mcp = FastMCP("Domain Availability Checker", host="0.0.0.0", port=int(os.environ.get("PORT", 8080)))
2122

2223
POPULAR_TLDS = [
2324
"com", "net", "org", "io", "ai", "app", "dev", "co", "xyz", "me", "info", "biz"
@@ -332,4 +333,7 @@ async def check_domain(domain_query: str) -> Dict:
332333
except Exception as e:
333334
return {
334335
"error": f"Failed to check domain: {str(e)}"
335-
}
336+
}
337+
338+
if __name__ == "__main__":
339+
mcp.run(transport="sse")

0 commit comments

Comments
 (0)