Skip to content

Commit f500126

Browse files
committed
add docker compose support for running Rust component
1 parent 0c317d7 commit f500126

2 files changed

Lines changed: 35 additions & 22 deletions

File tree

Dockerfile

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,46 @@
1+
# ---------------- RUST BUILD ----------------
12
FROM rust:1.89 AS rust-builder
2-
WORKDIR /app
3+
WORKDIR /workspace
34

45
COPY rustCode ./rustCode
5-
WORKDIR /app/rustCode
6+
WORKDIR /workspace/rustCode
67
RUN cargo build --release
7-
# ----------------------------
8+
9+
#--------------- GO BUILD --------------------
810
FROM golang:1.25 AS go-builder
9-
WORKDIR /app
11+
WORKDIR /workspace
1012

1113
COPY goCode ./goCode
1214

15+
# Rust shared lib
1316
COPY --from=rust-builder \
14-
/app/rustCode/target/release/librpc.so \
15-
/app/goCode/libs/librpc.so
17+
/workspace/rustCode/target/release/librpc.so \
18+
/workspace/goCode/libs/librpc.so
1619

17-
WORKDIR /app/goCode/goApp
20+
WORKDIR /workspace/goCode/goApp
1821
ENV CGO_ENABLED=1
1922
RUN go build -o app
2023

21-
# ----------------------------
24+
# ------------------ RUNTIME -----------
2225
FROM ubuntu:24.04
23-
WORKDIR /app/goCode/goApp
26+
WORKDIR /workspace
2427

2528
RUN apt-get update && apt-get install -y \
2629
ca-certificates \
2730
libc6 \
2831
&& rm -rf /var/lib/apt/lists/*
2932

3033
COPY --from=go-builder \
31-
/app/goCode/goApp/app \
32-
./app
34+
/workspace/goCode/goApp/app \
35+
/workspace/goCode/goApp/app
3336

34-
COPY --from=go-builder \
35-
/app/goCode/libs/librpc.so \
36-
../libs/librpc.so
37+
COPY --from=rust-builder \
38+
/workspace/rustCode/target/release/rustCode \
39+
/workspace/rustCode/rust-app
3740

38-
ENV LD_LIBRARY_PATH=/app/goCode/libs
41+
# Shared lib
42+
COPY --from=go-builder \
43+
/workspace/goCode/libs/librpc.so \
44+
/workspace/goCode/libs/librpc.so
3945

40-
CMD ["./app"]
46+
ENV LD_LIBRARY_PATH=/workspace/goCode/libs

docker-compose.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
services:
22
app:
3-
build:
4-
context: .
5-
dockerfile: Dockerfile
3+
build: .
64
image: blockchain-ffi
7-
container_name: blockchain-ffi
5+
container_name: blockchain-ffi-app
6+
working_dir: /workspace/goCode/goApp
7+
command: ./app
88
volumes:
9-
- ./goCode/.env:/app/goCode/.env
10-
# restart: unless-stopped
9+
- ./goCode/.env:/workspace/goCode/.env
10+
11+
rust:
12+
image: blockchain-ffi
13+
container_name: blockchain-ffi-rust
14+
working_dir: /workspace/rustCode
15+
command: ./rust-app
16+
volumes:
17+
- ./goCode/.env:/workspace/goCode/.env

0 commit comments

Comments
 (0)