-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
96 lines (76 loc) · 2.95 KB
/
Dockerfile
File metadata and controls
96 lines (76 loc) · 2.95 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
# Stage 1: Claude install
# FROM node:18-slim AS node-deps
#
# WORKDIR /app
#
# # Install pnpm globally
# RUN npm install -g pnpm
#
# # Copy package.json and install JavaScript dependencies
# COPY package.json ./
# RUN pnpm install
# Stage 1: Install bun from the official image
FROM oven/bun:1-slim AS bun-deps
RUN bun install -g @anthropic-ai/claude-code
# Stage 2: Python builder
FROM ghcr.io/astral-sh/uv:python3.11-bookworm-slim AS builder
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
ENV UV_PYTHON_DOWNLOADS=0
WORKDIR /app
# Install git with apt cache
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y \
git \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --locked --no-install-project --no-dev
# Copy application code
COPY . /app
# Install the project
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --no-dev
# Stage 3: Runtime
FROM python:3.11-slim-bookworm
# Install system dependencies with apt cache
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y \
curl wget ripgrep fd-find exa sed mawk procps\
build-essential \
git \
&& rm -rf /var/lib/apt/lists/*
# Copy Node.js binaries from node-deps stage
# COPY --from=node-deps /usr/local/bin/node /usr/local/bin/node
# COPY --from=node-deps /usr/local/bin/npm /usr/local/bin/npm
# COPY --from=node-deps /usr/local/bin/npx /usr/local/bin/npx
# COPY --from=node-deps /usr/local/bin/pnpm /usr/local/bin/pnpm
# COPY --from=node-deps /usr/local/lib/node_modules /usr/local/lib/node_modules
# We have to copy the entire /usr/local that seem to be
# more realiable
#COPY --from=node-deps /usr/local /usr/local
# Copy bun binaries from bun-deps stage and link to node
COPY --from=bun-deps /usr/local/bin/bun /usr/local/bin/
COPY --from=bun-deps /usr/local/bin/bunx /usr/local/bin/
RUN ln -s /usr/local/bin/bun /usr/local/bin/node && ln -s /usr/local/bin/bunx /usr/local/bin/npx
# Install package for claude and link to claude bin
COPY --from=bun-deps /root/.bun/install/global /app/bun_global
RUN ln -s /app/bun_global/node_modules/\@anthropic-ai/claude-code/cli.js /usr/local/bin/claude
# Copy Python application from builder
COPY --from=builder /app /app
WORKDIR /app
# ENV PATH="/app/.venv/bin:/app/node_modules/.bin:$PATH"
ENV PATH="/app/.venv/bin:/app/bun_global/bin:$PATH"
ENV PYTHONPATH=/app
ENV SERVER__HOST=0.0.0.0
ENV SERVER__PORT=8000
ENV LOGGING__LEVEL=INFO
ENV LOGGING__FORMAT=json
EXPOSE ${SERVER__PORT:-8000}
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:${SERVER__PORT:-8000}/health || exit 1
# Run the API server by default
CMD ["ccproxy"]