-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
85 lines (64 loc) · 2.34 KB
/
Dockerfile
File metadata and controls
85 lines (64 loc) · 2.34 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
# Multi-stage build for Zcash Block Scanner & Transaction Decryptor
# ============================================
# Stage 1: Build Rust Decryptor
# ============================================
FROM rust:slim AS rust-builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
pkg-config \
libssl-dev \
git \
&& rm -rf /var/lib/apt/lists/*
# Install nightly Rust toolchain for edition2024 support
RUN rustup default nightly
# Set working directory
WORKDIR /app
# Copy librustzcash dependency and Rust project
COPY librustzcash ./librustzcash
COPY zcash_tx_decryptor ./zcash_tx_decryptor
# Build the Rust decryptor in release mode
WORKDIR /app/zcash_tx_decryptor
RUN cargo build --release
# ============================================
# Stage 2: Build Node.js API
# ============================================
FROM node:18-slim AS node-builder
WORKDIR /app
# Copy package files
COPY block_scanner_api/package*.json ./
# Install dependencies
RUN npm ci --only=production
# Copy TypeScript source
COPY block_scanner_api/tsconfig.json ./
COPY block_scanner_api/src ./src
# Install TypeScript as dev dependency and build
RUN npm install --save-dev typescript @types/node @types/express @types/pg
RUN npm run build
# ============================================
# Stage 3: Production Image
# ============================================
FROM node:18-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Create app directory
WORKDIR /app
# Copy Node.js dependencies from builder
COPY --from=node-builder /app/node_modules ./node_modules
COPY --from=node-builder /app/dist ./dist
COPY --from=node-builder /app/package*.json ./
# Copy Rust binary from rust-builder
COPY --from=rust-builder /app/zcash_tx_decryptor/target/release/zcash-tx-decryptor /app/decryptor/zcash-tx-decryptor
# Set environment variables with Railway-friendly defaults
ENV PORT=3005 \
NODE_ENV=production \
DECRYPTOR_PATH=/app/decryptor/zcash-tx-decryptor
# Expose port
EXPOSE 3005
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3005/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1); });"
# Start the application
CMD ["node", "dist/index.js"]