mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2025-12-06 13:54:41 +08:00
- Upgrade Dockerfile to Go 1.24 with multi-stage build (backend + frontend) - Add TA-Lib installation for technical analysis support - Integrate frontend build into main container image - Add Nginx reverse proxy configuration for API routing - Update docker-compose.yml to simplified single-container architecture - Update .dockerignore to include web source for build - Improve health checks and startup time handling Benefits: - One-click deployment with single Docker image - Better resource utilization with multi-stage build - Production-ready Nginx frontend serving - Easier maintenance and deployment 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: tinkle-community <tinklefund@gmail.com>
104 lines
2.0 KiB
Docker
104 lines
2.0 KiB
Docker
# Multi-stage build for NOFX AI Trading System
|
|
FROM golang:1.24-alpine AS backend-builder
|
|
|
|
# Install build dependencies including TA-Lib
|
|
RUN apk add --no-cache \
|
|
git \
|
|
make \
|
|
gcc \
|
|
g++ \
|
|
musl-dev \
|
|
wget \
|
|
tar
|
|
|
|
# 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 && \
|
|
./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
|
|
|
|
# Install runtime dependencies
|
|
RUN apk add --no-cache \
|
|
ca-certificates \
|
|
tzdata \
|
|
wget \
|
|
tar \
|
|
make \
|
|
gcc \
|
|
g++ \
|
|
musl-dev
|
|
|
|
# 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 && \
|
|
./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"]
|