-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
77 lines (59 loc) · 2.32 KB
/
Dockerfile
File metadata and controls
77 lines (59 loc) · 2.32 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
# 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 signing patches
COPY diff/hyperliquid_signing.patch /tmp/hyperliquid_signing.patch
RUN pip show hyperliquid && \
cd $(python -c "import hyperliquid; import os; print(os.path.dirname(hyperliquid.__file__))") && \
patch -p1 < /tmp/hyperliquid_signing.patch || echo "Patch may have already been applied"
# 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
# Expose Flask server port
EXPOSE 8001
# # Set default environment variables (these should be overridden in production)
# ENV TRADING_AMOUNT=1.0 \
# MARKET_NAME="sol-usd" \
# TIMEZONE="Asia/Kolkata" \
# CANDLE_INTERVAL="PT1M"
# 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 app with gunicorn
CMD ["gunicorn", "--bind", "0.0.0.0:8001", "--workers", "1", "--threads", "4", "--worker-class", "sync", "main:application"]