Skip to content

Commit 02166e0

Browse files
committed
Docker cleanup
Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
1 parent d7a5773 commit 02166e0

2 files changed

Lines changed: 37 additions & 44 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ build-mcp: create-builder
3333
run-mcp: build-mcp
3434
docker run --rm -t -e OPENAI_API_KEY=$(OPENAI_API_KEY) -e TRANSPORT_TYPE=http --name mcp -p 3001:3001 $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(MCP_IMAGE_NAME):$(VERSION)
3535

36-
## To test the MCP image locally
37-
# docker run --rm -t -e OPENAI_API_KEY=$OPENAI_API_KEY -e TRANSPORT_TYPE=http -p 3001:3001 ghcr.io/kagent-dev/doc2vec/mcp:1.1.6
36+
## To test the MCP image locally
37+
# docker run --rm -t -e OPENAI_API_KEY=$OPENAI_API_KEY -e TRANSPORT_TYPE=http -p 3001:3001 ghcr.io/kagent-dev/doc2vec/mcp:1.1.6

mcp/Dockerfile

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,11 @@ ARG TARGETARCH
99

1010
ENV LANG=C.UTF-8
1111
ENV LC_ALL=C.UTF-8
12-
12+
# Install only runtime dependencies
1313
RUN apk update && apk add --no-cache \
14-
bash \
15-
build-base \
16-
ca-certificates \
17-
curl \
18-
make \
19-
node-gyp \
2014
nodejs \
21-
npm \
22-
openssl \
23-
python3 \
24-
sqlite-dev \
25-
unzip \
15+
ca-certificates \
2616
&& update-ca-certificates \
27-
&& rm -rf /var/cache/apk/*
2817

2918
WORKDIR /app
3019

@@ -33,30 +22,39 @@ COPY package.json package-lock.json tsconfig.json ./
3322
COPY src/ ./src/
3423

3524
# Install dependencies and build
36-
RUN --mount=type=cache,target=/root/.npm \
37-
npm install typescript && \
38-
npm ci --only=production && \
39-
npm install --save-dev typescript && \
40-
npm run build
41-
42-
# Production stage
43-
FROM cgr.dev/chainguard/wolfi-base:latest AS production
44-
45-
# Import build arguments for target platform
46-
ARG TARGETPLATFORM
47-
ARG TARGETOS
48-
ARG TARGETARCH
49-
50-
ENV LANG=C.UTF-8
51-
ENV LC_ALL=C.UTF-8
52-
ENV NODE_ENV=production
53-
54-
# Install only runtime dependencies
55-
RUN apk update && apk add --no-cache \
56-
nodejs \
57-
ca-certificates \
58-
sqlite \
59-
&& update-ca-certificates
25+
RUN echo "Building for platform: $TARGETPLATFORM" && \
26+
apk update && apk add --no-cache \
27+
bash \
28+
build-base \
29+
ca-certificates \
30+
curl \
31+
make \
32+
node-gyp \
33+
nodejs \
34+
npm \
35+
openssl \
36+
python3 \
37+
sqlite-dev \
38+
unzip && \
39+
echo "Installing dependencies" && \
40+
npm ci && \
41+
echo "Building application" && \
42+
npm run build && \
43+
echo "Cleaning up build... " && \
44+
npm prune --production && \
45+
apk del \
46+
bash \
47+
build-base \
48+
curl \
49+
make \
50+
node-gyp \
51+
openssl \
52+
python3 \
53+
sqlite-dev \
54+
unzip && \
55+
rm -rf /root/.npm /root/.node-gyp /root/.cache /tmp/* /var/tmp/* && \
56+
rm -rf /app/src /app/package.json /app/package-lock.json /app/tsconfig.json \
57+
echo "Build completed successfully"
6058

6159
# Create non-root user
6260
RUN addgroup -g 1001 -S nodejs && \
@@ -85,11 +83,6 @@ RUN for file in /app/build/*.db; do echo "Checksum for $file:";sha256sum "$file"
8583
# Ensure the app directory is owned by the non-root user
8684
RUN chown -R kagent:nodejs /app
8785

88-
# Copy built application and production dependencies from builder stage
89-
COPY --from=builder --chown=kagent:nodejs /app/build ./build
90-
COPY --from=builder --chown=kagent:nodejs /app/node_modules ./node_modules
91-
COPY --from=builder --chown=kagent:nodejs /app/package.json ./
92-
9386
LABEL org.opencontainers.image.source=https://github.com/kagent-dev/doc2vec
9487
LABEL org.opencontainers.image.description="Kagent Doc2Vec MCP"
9588
LABEL org.opencontainers.image.authors="Kagent Creators 🤖"

0 commit comments

Comments
 (0)