-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (54 loc) · 1.74 KB
/
Dockerfile
File metadata and controls
67 lines (54 loc) · 1.74 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
# Multi-stage build for faster Cloud Run deployment
FROM node:18-slim as cpp-builder
# Install system dependencies for C++ build
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
git \
curl \
pkg-config \
libssl-dev \
libcurl4-openssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy C++ source
WORKDIR /cpp
COPY quantlab-cpp/ ./
# Build existing strategy optimizer with backtesting engine
# Build institutional backtest (the real tested backtesting engine)
RUN rm -rf build CMakeCache.txt && \
mkdir build && cd build && \
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS="-O2 -DNDEBUG" && \
make strategy_optimizer -j1 && \
cp apps/strategy_optimizer ../strategy_optimizer
# Production stage
FROM node:18-slim
# Install minimal runtime dependencies
RUN apt-get update && apt-get install -y \
curl \
libssl3 \
libcurl4 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy Node.js dependencies
COPY package.json ./
RUN npm install --production --no-audit
# Copy built C++ binary and required shared libraries from builder stage
# Copy built C++ binary and required shared libraries from builder stage
COPY --from=cpp-builder /cpp/strategy_optimizer ./strategy_optimizer
COPY --from=cpp-builder /cpp/build/_deps/cpr-build/cpr/libcpr.so* ./
# Copy Node.js server
COPY server.js ./
# Set environment variables
ENV NODE_ENV=production
ENV PORT=8080
ENV ALPACA_PAPER=1
ENV ALPACA_BASE_URL=https://paper-api.alpaca.markets/v2
ENV LD_LIBRARY_PATH=/app
# Expose port for Cloud Run
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
# Start the server
CMD ["node", "server.js"]