-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathDockerfile
More file actions
63 lines (46 loc) · 1.98 KB
/
Dockerfile
File metadata and controls
63 lines (46 loc) · 1.98 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
# Claude Code Discord Bot
# Optimized production image with Claude CLI
FROM denoland/deno:latest
# Build arguments for user UID/GID (match host user to avoid permission issues)
ARG USER_ID=1000
ARG GROUP_ID=1000
# Set working directory
WORKDIR /app
# Set environment variable to indicate Docker container
ENV DOCKER_CONTAINER=true
# Install system dependencies
USER root
RUN apt-get update && \
apt-get install -y --no-install-recommends git curl ca-certificates nodejs npm && \
rm -rf /var/lib/apt/lists/*
# Create non-root user with home directory (needed for Claude CLI config)
RUN groupadd -r -g ${GROUP_ID} claude && \
useradd -r -u ${USER_ID} -g claude -m claude
# Install Claude Code CLI globally via npm
RUN npm install -g @anthropic-ai/claude-code && \
npm cache clean --force
# Verify claude binary is accessible
RUN claude --version
# Copy all source files (as root)
COPY . .
# Remove lockfile if present (avoid version conflicts)
RUN rm -f deno.lock
# Initialize git repo in container (for non-git workspaces)
RUN git init && git config user.email "bot@claude.local" && git config user.name "Claude Bot"
# Pre-compile Deno dependencies
RUN deno cache --no-lock index.ts
# Create data directory for persistence + workspace dir, set ownership
RUN mkdir -p .bot-data /app/workspace /home/claude/.claude && \
cd /app/workspace && git init && git config user.email "bot@claude.local" && git config user.name "Claude Bot" && \
chown -R claude:claude /app /home/claude
# Switch to non-root user
USER claude
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD deno eval "console.log('healthy')" || exit 1
# Default command
CMD ["deno", "run", "--allow-all", "--no-lock", "index.ts"]
# Labels for image metadata
LABEL org.opencontainers.image.source="https://github.com/zebbern/claude-code-discord"
LABEL org.opencontainers.image.description="Claude Code Discord Bot - Use Claude AI via Discord"
LABEL org.opencontainers.image.licenses="MIT"