-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathDockerfile
More file actions
121 lines (101 loc) · 4.36 KB
/
Copy pathDockerfile
File metadata and controls
121 lines (101 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# Build stage
FROM --platform=$TARGETPLATFORM cgr.dev/chainguard/wolfi-base:latest AS builder
# Import build arguments for cross-compilation
ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
ENV NODE_ENV=production
ENV NODE_PATH=/app/node_modules
# Install only runtime dependencies
RUN apk update && apk add --no-cache \
nodejs \
ca-certificates \
&& update-ca-certificates
WORKDIR /app
# Copy package files first for better layer caching
COPY package.json package-lock.json tsconfig.json ./
COPY src/ ./src/
# Install dependencies and build
RUN echo "Building for platform: $TARGETPLATFORM" && \
apk update && apk add --no-cache \
bash \
build-base \
ca-certificates \
curl \
make \
node-gyp \
nodejs \
npm \
openssl \
python3 \
sqlite-dev \
unzip && \
echo "🤖 Installing ..." && \
npm ci --include=dev && \
echo "🤖 Building ..." && \
npm run build && \
echo "🤖 Cleaning up..." && \
npm prune --production && \
apk del \
bash \
build-base \
curl \
make \
node-gyp \
openssl \
python3 \
sqlite-dev \
unzip && \
rm -rf /root/.npm /root/.node-gyp /root/.cache /tmp/* /var/tmp/* && \
rm -rf /app/src /app/package.json /app/package-lock.json /app/tsconfig.json && \
find /app/build/ && \
echo "🤖 Build completed !!!"
# Final stage - use target platform
FROM cgr.dev/chainguard/wolfi-base:latest
# Import build arguments for cross-compilation
ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
ENV NODE_ENV=production
ENV NODE_PATH=/app/node_modules
# Install only runtime dependencies for target platform
RUN apk update && apk add --no-cache \
nodejs \
ca-certificates
WORKDIR /app
# Copy built artifacts from builder stage
COPY --from=builder /app/build /app/build
COPY --from=builder /app/node_modules /app/node_modules
# Create non-root user and verify build directory
RUN addgroup -g 14000 -S doc2vec && \
adduser -S doc2vec -u 14000 -G doc2vec
ADD https://doc-sqlite-db.s3.sa-east-1.amazonaws.com/kubernetes.db /app/build/kubernetes.db
ADD https://doc-sqlite-db.s3.sa-east-1.amazonaws.com/istio.db /app/build/istio.db
ADD https://doc-sqlite-db.s3.sa-east-1.amazonaws.com/argo.db /app/build/argo.db
ADD https://doc-sqlite-db.s3.sa-east-1.amazonaws.com/argo-rollouts.db /app/build/argo-rollouts.db
ADD https://doc-sqlite-db.s3.sa-east-1.amazonaws.com/helm.db /app/build/helm.db
ADD https://doc-sqlite-db.s3.sa-east-1.amazonaws.com/prometheus.db /app/build/prometheus.db
ADD https://doc-sqlite-db.s3.sa-east-1.amazonaws.com/gateway-api.db /app/build/gateway-api.db
ADD https://doc-sqlite-db.s3.sa-east-1.amazonaws.com/gloo-gateway.db /app/build/gloo-gateway.db
ADD https://doc-sqlite-db.s3.sa-east-1.amazonaws.com/kgateway.db /app/build/kgateway.db
ADD https://doc-sqlite-db.s3.sa-east-1.amazonaws.com/gloo-edge.db /app/build/gloo-edge.db
ADD https://doc-sqlite-db.s3.sa-east-1.amazonaws.com/otel.db /app/build/otel.db
ADD https://doc-sqlite-db.s3.sa-east-1.amazonaws.com/cilium.db /app/build/cilium.db
ADD https://doc-sqlite-db.s3.sa-east-1.amazonaws.com/ambient.db /app/build/ambient.db
#show cheksum for every db file
RUN for file in /app/build/*.db; do echo "Checksum for $file:";sha256sum "$file";done
# Ensure the app directory is owned by the non-root user
RUN chown -R doc2vec:doc2vec /app
LABEL org.opencontainers.image.source=https://github.com/kagent-dev/doc2vec
LABEL org.opencontainers.image.description="Kagent Doc2Vec MCP"
LABEL org.opencontainers.image.authors="Kagent Creators 🤖"
EXPOSE 3001
# Run as the numeric non-root UID so kubelet can enforce runAsNonRoot
USER 14000
ENTRYPOINT ["node", "build/index.js"]