Skip to content

Commit be81d0b

Browse files
Add Dockerfile and Docker documentation
1 parent 76caa8f commit be81d0b

File tree

2 files changed

+193
-0
lines changed

2 files changed

+193
-0
lines changed

DOCKER.md

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# Running the MCP Server with Docker
2+
3+
This document provides instructions on how to build and run the Model Context Protocol (MCP) server using Docker.
4+
5+
## Building the Image
6+
7+
You can build the Docker image in two ways: from a local clone of the repository or directly from GitHub.
8+
9+
### Building from a Local Clone
10+
11+
First, build the Docker image from the root of the project:
12+
13+
```sh
14+
docker build -t cloudinary-asset-management-mcp .
15+
```
16+
17+
### Building from GitHub
18+
19+
You can also build the image directly from the GitHub repository without cloning it first.
20+
21+
```sh
22+
docker build -t cloudinary-asset-management-mcp https://github.com/cloudinary/asset-management-mcp.git
23+
```
24+
25+
## Running the Container
26+
27+
The MCP server requires Cloudinary credentials to run. You can provide these credentials in one of three ways. When running the `docker run` command, you will also map a local port (e.g., `2718`) to the container's port `2718`.
28+
29+
**Note:** Replace `<your_cloud_name>`, `<your_api_key>`, and `<your_api_secret>` with your actual Cloudinary credentials.
30+
31+
### Option 1: Using Individual Environment Variables
32+
33+
This is the recommended method.
34+
35+
```sh
36+
docker run -d -p 2718:2718 \
37+
-e CLOUDINARY_CLOUD_NAME="<your_cloud_name>" \
38+
-e CLOUDINARY_API_KEY="<your_api_key>" \
39+
-e CLOUDINARY_API_SECRET="<your_api_secret>" \
40+
cloudinary-asset-management-mcp start --transport sse
41+
```
42+
43+
**Note:** If you have these variables already set in your shell environment, you can pass them directly to the container without specifying the values:
44+
45+
```sh
46+
docker run -d -p 2718:2718 \
47+
-e CLOUDINARY_CLOUD_NAME \
48+
-e CLOUDINARY_API_KEY \
49+
-e CLOUDINARY_API_SECRET \
50+
cloudinary-asset-management-mcp start --transport sse
51+
```
52+
53+
### Option 2: Using Command-Line Arguments
54+
55+
You can also provide the credentials as arguments to the `start` command.
56+
57+
```sh
58+
docker run -d -p 2718:2718 \
59+
cloudinary-asset-management-mcp start --transport sse \
60+
--cloud-name "<your_cloud_name>" \
61+
--api-key "<your_api_key>" \
62+
--api-secret "<your_api_secret>"
63+
```
64+
65+
### Option 3: Using `CLOUDINARY_URL` Environment Variable
66+
67+
This method combines all credentials into a single URL.
68+
69+
```sh
70+
docker run -d -p 2718:2718 \
71+
-e CLOUDINARY_URL="cloudinary://<your_api_key>:<your_api_secret>@<your_cloud_name>" \
72+
cloudinary-asset-management-mcp start --transport sse
73+
```
74+
75+
**Note:** If you have the `CLOUDINARY_URL` variable already set in your shell environment, you can pass it directly:
76+
77+
```sh
78+
docker run -d -p 2718:2718 -e CLOUDINARY_URL cloudinary-asset-management-mcp start --transport sse
79+
```
80+
81+
## Connecting to the Server
82+
83+
Once the container is running with the SSE transport enabled (as shown in the commands above), the MCP server is available at the following endpoint:
84+
85+
`http://localhost:2718/sse`
86+
87+
If you are running Docker on a different host, replace `localhost` with the appropriate hostname or IP address.
88+
89+
## Stopping the Container
90+
91+
You can find the container ID by running `docker ps` and then stop it using `docker stop`.
92+
93+
To stop the container started from the `cloudinary-asset-management-mcp` image:
94+
```sh
95+
docker stop $(docker ps -a -q --filter "ancestor=cloudinary-asset-management-mcp")
96+
```
97+
98+
## Viewing Logs
99+
100+
You can view the logs from your running container to monitor its output or troubleshoot issues.
101+
102+
First, find the ID of your container:
103+
```sh
104+
docker ps
105+
```
106+
This will list all running containers, including their IDs.
107+
108+
### Static Logs
109+
110+
To see all logs that have been generated so far, use the `docker logs` command with the container ID.
111+
112+
```sh
113+
docker logs <your_container_id>
114+
```
115+
116+
### Live Logs
117+
118+
To see logs in real time, add the `--follow` (or `-f`) flag.
119+
120+
```sh
121+
docker logs --follow <your_container_id>
122+
```
123+
124+
Press `Ctrl+C` to stop following the logs.
125+
126+
## Debugging
127+
128+
You can enable more detailed logging for troubleshooting in two ways.
129+
130+
### Using the `--log-level` Flag
131+
132+
Set the `--log-level` flag to `debug` when starting the container.
133+
134+
```sh
135+
docker run -d -p 2718:2718 \
136+
-e CLOUDINARY_URL \
137+
cloudinary-asset-management-mcp start --transport sse --log-level debug
138+
```
139+
140+
### Using the `CLOUDINARY_DEBUG` Environment Variable
141+
142+
You can also enable a debug logger by setting the `CLOUDINARY_DEBUG` environment variable to `true`.
143+
144+
```sh
145+
docker run -d -p 2718:2718 \
146+
-e CLOUDINARY_URL \
147+
-e CLOUDINARY_DEBUG=true \
148+
cloudinary-asset-management-mcp start --transport sse
149+
```
150+

Dockerfile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# --- Builder Stage ---
2+
FROM node:22-alpine AS builder
3+
WORKDIR /app
4+
5+
# Install bun
6+
RUN apk add --no-cache bash curl unzip && \
7+
(unset OS; unset SHELL; curl -fsSL https://bun.sh/install | bash)
8+
9+
# Add bun to the PATH
10+
ENV PATH="/root/.bun/bin:$PATH"
11+
12+
# Copy dependency manifests
13+
COPY package.json package-lock.json tsconfig.json ./
14+
15+
# Install dependencies
16+
RUN bun install --ignore-scripts
17+
18+
# Copy the rest of the source code
19+
COPY . .
20+
21+
# Build the application
22+
RUN bun src/mcp-server/build.mts && npx tsc
23+
24+
25+
# --- Release Stage ---
26+
FROM node:22-alpine AS release
27+
WORKDIR /app
28+
29+
ENV NODE_ENV=production
30+
31+
# Copy dependency manifests from builder
32+
COPY --from=builder /app/package.json /app/package-lock.json ./
33+
34+
# Install production-only dependencies
35+
RUN --mount=type=cache,target=/root/.npm \
36+
npm ci --ignore-scripts --omit=dev --prefer-offline --no-audit --progress=false
37+
38+
# Copy built server from builder stage
39+
COPY --from=builder /app/bin ./bin
40+
41+
# Entrypoint to run the MCP server
42+
ENTRYPOINT ["node", "bin/mcp-server.js"]
43+

0 commit comments

Comments
 (0)