-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile.slack
More file actions
72 lines (45 loc) · 2.01 KB
/
Dockerfile.slack
File metadata and controls
72 lines (45 loc) · 2.01 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
FROM node:24-alpine AS builder
# Install git for package installation support
RUN apk add --no-cache git ca-certificates
# Configure npm for faster installations in containerized environments
ENV NODE_ENV=production \
NPM_CONFIG_LOGLEVEL=error \
NPM_CONFIG_FUND=false \
NPM_CONFIG_AUDIT=false \
NPM_CONFIG_UPDATE_NOTIFIER=false \
NPM_CONFIG_PROGRESS=false
# Set working directory for package installation
WORKDIR /build
# Create a package.json to install the MCP package
RUN echo '{"name":"mcp-container","version":"1.0.0"}' > package.json
# Install the MCP package and its dependencies at build time
# This ensures all dependencies are downloaded during the build phase
RUN npm install --save @ubie-oss/slack-mcp-server@0.1.4
# Final stage - runtime image with pre-installed packages
FROM node:24-alpine
# Install runtime dependencies
RUN apk add --no-cache ca-certificates
# Set working directory
WORKDIR /app
# Create a non-root user to run the application
RUN addgroup -S appgroup && \
adduser -S appuser -G appgroup && \
mkdir -p /app && \
chown -R appuser:appgroup /app
# Copy the installed node_modules from builder stage
COPY --from=builder --chown=appuser:appgroup /build/node_modules /app/node_modules
# Copy package.json to maintain the dependency tree
COPY --from=builder --chown=appuser:appgroup /build/package.json /app/package.json
COPY --from=builder --chown=appuser:appgroup /build/package-lock.json /app/package-lock.json
# Set NODE_PATH to find the pre-installed modules
ENV NODE_PATH=/app/node_modules \
PATH=/app/node_modules/.bin:$PATH
# Switch to non-root user
USER appuser
# `MCPPackage` may include a version suffix (e.g., `package@1.2.3`), which we cannot use here.
# Create a small wrapper script to handle this.
RUN echo "#!/bin/sh" >> entrypoint.sh && \
echo "exec npx $(echo @ubie-oss/slack-mcp-server@0.1.4 | sed 's/@[^@/]*$//')" >> entrypoint.sh && \
chmod +x entrypoint.sh
# Run the preinstalled MCP package directly using npx.
ENTRYPOINT ["./entrypoint.sh"]