forked from NoFxAiOS/nofx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
123 lines (99 loc) · 2.78 KB
/
Dockerfile
File metadata and controls
123 lines (99 loc) · 2.78 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Multi-stage build for NOFX AI Trading System
FROM golang:1.25-alpine AS backend-builder
# Install build dependencies including TA-Lib
RUN apk update && \
apk add --no-cache \
git \
make \
gcc \
g++ \
musl-dev \
wget \
tar \
autoconf \
automake
# Install TA-Lib
RUN wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz && \
tar -xzf ta-lib-0.4.0-src.tar.gz && \
cd ta-lib && \
if [ "$(uname -m)" = "aarch64" ]; then \
CONFIG_GUESS=$(find /usr/share -name config.guess | head -1) && \
CONFIG_SUB=$(find /usr/share -name config.sub | head -1) && \
cp "$CONFIG_GUESS" config.guess && \
cp "$CONFIG_SUB" config.sub && \
chmod +x config.guess config.sub; \
fi && \
./configure --prefix=/usr && \
make && \
make install && \
cd .. && \
rm -rf ta-lib ta-lib-0.4.0-src.tar.gz
# Set working directory
WORKDIR /app
# Copy go mod files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy backend source code
COPY . .
# Build the application
RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o nofx .
# Frontend build stage
FROM node:18-alpine AS frontend-builder
WORKDIR /app/web
# Copy package files
COPY web/package*.json ./
# Install dependencies
RUN npm ci
# Copy frontend source
COPY web/ ./
# Build frontend
RUN npm run build
# Final stage
FROM alpine:latest
# Update package index and install runtime dependencies
RUN apk update && \
apk add --no-cache \
ca-certificates \
tzdata \
wget \
tar \
make \
gcc \
g++ \
musl-dev \
autoconf \
automake
# Install TA-Lib runtime
RUN wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz && \
tar -xzf ta-lib-0.4.0-src.tar.gz && \
cd ta-lib && \
if [ "$(uname -m)" = "aarch64" ]; then \
CONFIG_GUESS=$(find /usr/share -name config.guess | head -1) && \
CONFIG_SUB=$(find /usr/share -name config.sub | head -1) && \
cp "$CONFIG_GUESS" config.guess && \
cp "$CONFIG_SUB" config.sub && \
chmod +x config.guess config.sub; \
fi && \
./configure --prefix=/usr && \
make && \
make install && \
cd .. && \
rm -rf ta-lib ta-lib-0.4.0-src.tar.gz
# Set timezone to UTC
ENV TZ=UTC
WORKDIR /app
# Copy backend binary from builder
COPY --from=backend-builder /app/nofx .
# Copy frontend build from builder
COPY --from=frontend-builder /app/web/dist ./web/dist
# Create directories for logs and data
RUN mkdir -p /app/decision_logs
# Expose ports
# 8080 for backend API
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
# Run the application
CMD ["./nofx"]