forked from Stellar-Uzima/Uzima-Contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockerfile
More file actions
80 lines (57 loc) · 1.64 KB
/
Copy pathdockerfile
File metadata and controls
80 lines (57 loc) · 1.64 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
# Multi-stage Dockerfile for Soroban development
# Build stage
FROM rust:1.75-slim as builder
# Install system dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
curl \
git \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Install Rust targets and components
RUN rustup target add wasm32-unknown-unknown && \
rustup component add rustfmt clippy
# Install Soroban CLI
RUN cargo install --locked soroban-cli --features opt
# Set working directory
WORKDIR /workspace
# Copy manifests
COPY Cargo.toml rust-toolchain.toml ./
COPY contracts/ ./contracts/
# Build dependencies (this layer will be cached)
RUN cargo fetch
# Development stage
FROM builder as development
# Install additional development tools
RUN cargo install cargo-watch cargo-audit
# Copy source code
COPY . .
# Set up environment
ENV RUST_BACKTRACE=1
ENV CARGO_TERM_COLOR=always
# Expose port for local Stellar network
EXPOSE 8000
CMD ["/bin/bash"]
# Production build stage
FROM builder as production
# Copy source code
COPY . .
# Build optimized contracts
RUN cargo build --release --target wasm32-unknown-unknown
# Runtime stage
FROM debian:bookworm-slim as runtime
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy Soroban CLI from builder
COPY --from=builder /usr/local/cargo/bin/soroban /usr/local/bin/
# Copy built contracts
COPY --from=production /workspace/contracts/*/target/wasm32-unknown-unknown/release/*.wasm /contracts/
# Copy scripts
COPY scripts/ /scripts/
RUN chmod +x /scripts/*.sh
WORKDIR /workspace
CMD ["/bin/bash"]