-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbb.Dockerfile
More file actions
67 lines (51 loc) · 1.9 KB
/
bb.Dockerfile
File metadata and controls
67 lines (51 loc) · 1.9 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
# Use Python 3.13 slim image as base
FROM python:3.13-slim
# Set working directory
WORKDIR /app
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
patch \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first for better caching
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy and apply hibachi-xyz compatibility fixes
COPY scripts/fix_hibachi_compatibility.py /tmp/fix_hibachi_compatibility.py
RUN pip show hibachi-xyz && \
python /tmp/fix_hibachi_compatibility.py docker
# Copy and apply hyperliquid patches
COPY scripts/apply_hyperliquid_patches.py /tmp/apply_hyperliquid_patches.py
RUN pip show hyperliquid-python-sdk && \
python /tmp/apply_hyperliquid_patches.py docker
# Copy the application code
COPY . .
# Create a non-root user for security
RUN useradd --create-home --shell /bin/bash app
# Create logs and data directories
RUN mkdir -p logs data
# Create entrypoint script to fix permissions
RUN echo '#!/bin/bash\n\
# Fix permissions for mounted volumes\n\
chown -R app:app /app/logs /app/data 2>/dev/null || true\n\
# Switch to app user and execute the main command\n\
exec gosu app "$@"' > /entrypoint.sh && \
chmod +x /entrypoint.sh
# Install gosu for user switching
RUN apt-get update && apt-get install -y gosu && rm -rf /var/lib/apt/lists/*
# Set ownership of the app directory
RUN chown -R app:app /app
# Health check (optional)
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import sys; sys.exit(0)"
# Set entrypoint to fix permissions
ENTRYPOINT ["/entrypoint.sh"]
# Default command to run the bollinger bands strategy
CMD ["python3", "./strategies/bollinger_bands.py"]