forked from Drakkar-Software/Triangular-Arbitrage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
84 lines (61 loc) · 1.79 KB
/
Copy pathDockerfile
File metadata and controls
84 lines (61 loc) · 1.79 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
# Multi-stage Docker build for triangular arbitrage system with web dashboard
# Stage 1: Build React frontend
FROM node:18-alpine AS frontend-builder
WORKDIR /app/web_ui
COPY web_ui/package*.json ./
RUN npm install
COPY web_ui/ ./
RUN npm run build
# Stage 2: Python backend
FROM python:3.10-slim as base
# Install system dependencies required for the application
RUN apt-get update && apt-get install -y \
gcc \
g++ \
make \
git \
curl \
&& rm -rf /var/lib/apt/lists/*
# Set up working directory
WORKDIR /app
# Create non-root user for security
RUN groupadd -r appuser && useradd -r -g appuser appuser
# Copy requirements first for better Docker layer caching
COPY requirements.txt ./
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy the entire repository
COPY . .
# Copy built React frontend from builder stage
COPY --from=frontend-builder /app/web_ui/build /app/web_ui/build
# Install the application in development mode
RUN pip install -e .
# Create logs directory
RUN mkdir -p logs
# Change ownership to non-root user
RUN chown -R appuser:appuser /app
USER appuser
# Set environment variables
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
ENV TRADING_MODE=paper
# Expose web server port
EXPOSE 8000
# Default command runs the web server
CMD ["python", "web_server.py"]
# Development stage with additional tools
FROM base as dev
# Switch back to root to install additional dev tools
USER root
# Install additional development utilities
RUN apt-get update && apt-get install -y \
vim \
htop \
&& rm -rf /var/lib/apt/lists/*
USER appuser
# Development command launches interactive shell
CMD ["/bin/bash"]
# Production stage - minimal runtime
FROM base as prod
# Production command runs the web server
CMD ["python", "web_server.py"]