forked from snipeship/ccflare
-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathDockerfile
More file actions
103 lines (87 loc) · 3.62 KB
/
Copy pathDockerfile
File metadata and controls
103 lines (87 loc) · 3.62 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
# Simplified Dockerfile using pre-built binaries from GitHub Releases
# Supports: linux/amd64, linux/arm64
ARG VERSION=latest
FROM debian:bookworm-slim
# Install required dependencies
RUN apt-get update && \
apt-get install -y \
sqlite3 \
ca-certificates \
curl \
file \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Download the appropriate binary based on architecture
# TARGETARCH is automatically set by Docker buildx (amd64 or arm64)
ARG TARGETARCH
ARG VERSION
# Determine correct architecture and download binary
RUN echo "=== Binary Download Information ===" && \
echo "TARGETARCH from buildx: ${TARGETARCH}" && \
echo "System uname -m: $(uname -m)" && \
echo "Version: ${VERSION}" && \
# Use TARGETARCH if set, otherwise detect from system
if [ -z "${TARGETARCH}" ]; then \
case "$(uname -m)" in \
x86_64) ARCH=amd64 ;; \
aarch64) ARCH=arm64 ;; \
*) echo "Unsupported architecture: $(uname -m)"; exit 1 ;; \
esac; \
else \
ARCH="${TARGETARCH}"; \
fi && \
echo "Using architecture: ${ARCH}" && \
if [ "${VERSION}" = "latest" ]; then \
DOWNLOAD_URL="https://github.com/tombii/better-ccflare/releases/latest/download/better-ccflare-linux-${ARCH}"; \
else \
DOWNLOAD_URL="https://github.com/tombii/better-ccflare/releases/download/v${VERSION}/better-ccflare-linux-${ARCH}"; \
fi && \
echo "Downloading from: ${DOWNLOAD_URL}" && \
curl -L -f -o /usr/local/bin/better-ccflare "${DOWNLOAD_URL}" || (echo "Failed to download binary from ${DOWNLOAD_URL}"; exit 1) && \
chmod +x /usr/local/bin/better-ccflare && \
echo "Binary downloaded successfully" && \
file /usr/local/bin/better-ccflare && \
# Verify the binary can execute (basic sanity check)
/usr/local/bin/better-ccflare --version || (echo "Binary verification failed - exec format error"; exit 1) && \
echo "==================================="
# Create a non-root user to run the application
RUN useradd -r -u 1000 -m -s /bin/bash ccflare && \
mkdir -p /data && \
chown -R ccflare:ccflare /data /app
# Set environment variables
ENV NODE_ENV=production
ENV BETTER_CCFLARE_DB_PATH=/data/better-ccflare.db
ENV XDG_CONFIG_HOME=/data
ENV BETTER_CCFLARE_LOG_DIR=/app/logs
# Create logs directory with proper permissions
RUN mkdir -p /app/logs /data && chown -R ccflare:ccflare /app/logs /data
# Expose default port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
# Add labels for version tracking (will be overridden by GitHub Actions metadata)
ARG VERSION
LABEL org.opencontainers.image.version="${VERSION}"
LABEL org.opencontainers.image.title="better-ccflare"
LABEL org.opencontainers.image.description="Load balancer proxy for Claude API with intelligent distribution across multiple OAuth accounts"
LABEL org.opencontainers.image.source="https://github.com/tombii/better-ccflare"
# Create startup script that shows version
RUN echo '#!/bin/bash\n\
echo "================================="\n\
echo "better-ccflare Docker Container"\n\
echo "================================="\n\
echo "Architecture: $(uname -m)"\n\
echo ""\n\
/usr/local/bin/better-ccflare --version\n\
echo "================================="\n\
echo ""\n\
exec /usr/local/bin/better-ccflare "$@"\n\
' > /usr/local/bin/entrypoint.sh && chmod +x /usr/local/bin/entrypoint.sh
# Switch to non-root user
USER ccflare
# Add volume mount for persistent data only
VOLUME ["/data"]
# Use the startup script as entrypoint
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["--serve", "--port", "8080"]