-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile.github
More file actions
135 lines (107 loc) · 3.41 KB
/
Dockerfile.github
File metadata and controls
135 lines (107 loc) · 3.41 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
124
125
126
127
128
129
130
131
132
133
134
135
# syntax=docker/dockerfile:1
#
# Dockerfile.github - Ubuntu-based build simulating GitHub Actions runner
# Based on Solana's comprehensive Docker setup with Turso dependencies
#
# This Dockerfile builds in an Ubuntu environment to simulate GitHub Actions
##########################################
## 1️⃣ Base Builder Stage (Ubuntu) ##
##########################################
FROM ubuntu:20.04 AS builder
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=UTC
ENV PATH="$PATH:/root/.cargo/bin"
# Install comprehensive dependencies for Solana, Turso, and OpenSSL
RUN apt-get update && \
apt-get install --no-install-recommends -y \
# Basic build tools
build-essential \
git \
curl \
ca-certificates \
pkg-config \
cmake \
make \
# OpenSSL and crypto libraries
libssl-dev \
libssl1.1 \
# Solana dependencies
libudev-dev \
zlib1g-dev \
llvm \
clang \
libprotobuf-dev \
protobuf-compiler \
libclang-dev \
# Additional system libraries
libudev1 \
&& rm -rf /var/lib/apt/lists/*
# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
sh -s -- --no-modify-path --profile minimal --default-toolchain stable -y && \
rustup component add rustfmt clippy && \
rustup target add x86_64-unknown-linux-gnu
# Install cargo-chef for optimized caching
RUN cargo install cargo-chef --version 0.1.72
WORKDIR /app
##########################################
## 2️⃣ Chef Stage (cargo-chef) ##
##########################################
FROM builder AS chef
# Copy all the source files for dependency planning
COPY Cargo.toml Cargo.lock ./
COPY crates/ ./crates/
COPY protocols/ ./protocols/
# Prepare the recipe for building dependencies
RUN cargo chef prepare --recipe-path recipe.json
##########################################
## 3️⃣ Build Stage ##
##########################################
FROM builder AS build
# Copy the recipe from chef stage
COPY --from=chef /app/recipe.json recipe.json
# Build dependencies using the recipe
RUN PROTOC=/usr/bin/protoc \
PKG_CONFIG_ALLOW_CROSS=1 \
cargo chef cook --release --recipe-path recipe.json
# Copy the actual source code
COPY Cargo.toml Cargo.lock ./
COPY crates/ ./crates/
COPY protocols/ ./protocols/
# Build the actual application binaries
RUN PROTOC=/usr/bin/protoc \
PKG_CONFIG_ALLOW_CROSS=1 \
cargo build --release \
--package reev-agent \
--package reev-api \
--package reev-runner
##########################################
## 4️⃣ Runtime Stage ##
##########################################
FROM ubuntu:20.04
# Install runtime dependencies
RUN apt-get update && \
apt-get install --no-install-recommends -y \
ca-certificates \
curl \
libssl1.1 \
libudev1 \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN groupadd -r app && \
useradd -r -u 1000 -g app app
WORKDIR /app
# Copy the compiled binaries
COPY --from=build /app/target/release/reev-agent /app/reev-agent
COPY --from=build /app/target/release/reev-api /app/reev-api
COPY --from=build /app/target/release/reev-runner /app/reev-runner
# Set ownership
RUN chown -R app:app /app
# Expose ports
EXPOSE 8080 9090 9091
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s \
CMD curl -f http://localhost:9090/health || exit 1
USER app
ENTRYPOINT ["/app/reev-api"]