Skip to content

Commit c158c70

Browse files
committed
Dockerize backend
1 parent 2282403 commit c158c70

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

backend/.dockerignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Git files
2+
.git
3+
.gitignore
4+
.github
5+
6+
# Build artifacts
7+
target/
8+
9+
# Documentation
10+
*.md
11+
README*
12+
CHANGELOG*
13+
14+
# Docker files
15+
.dockerignore
16+
Dockerfile*
17+
docker-compose*
18+
19+
# IDE and editor files
20+
.vscode
21+
.idea
22+
*.iml
23+
.DS_Store
24+
*.swp
25+
*.swo
26+
*~
27+
28+
# Environment files
29+
.env
30+
.env.local
31+
.env.*.local
32+
33+
# Test and coverage
34+
*.test
35+
coverage/
36+
.nyc_output
37+
38+
# Logs
39+
*.log
40+
logs/

backend/Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM rust:1.91-slim
2+
3+
# Install build dependencies
4+
RUN apt-get update && apt-get install -y \
5+
git \
6+
curl \
7+
gcc \
8+
g++ \
9+
cmake \
10+
pkg-config \
11+
libssl-dev \
12+
libclang-dev \
13+
libzstd-dev \
14+
libhugetlbfs-dev \
15+
&& rm -rf /var/lib/apt/lists/*
16+
17+
# Set working directory
18+
WORKDIR /usr/src/app
19+
20+
# Copy all source files
21+
COPY . .
22+
23+
# Build the binary
24+
RUN cargo build --release --bin backend
25+
26+
# Expose WebSocket port
27+
EXPOSE 8443
28+
29+
# Set entrypoint with default server address for container
30+
ENTRYPOINT ["cargo", "run", "--release", "--bin", "backend", "--"]
31+
CMD ["--server-addr", "0.0.0.0:8443"]

docker-compose.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: '3.9'
2+
3+
services:
4+
backend:
5+
build:
6+
context: ./backend
7+
dockerfile: Dockerfile
8+
container_name: backend
9+
network_mode: host
10+
environment:
11+
- RUST_LOG=info
12+
volumes:
13+
# Mount the Monad event ring (read-only)
14+
# Note: Update the host path if your event ring is located elsewhere
15+
- /var/lib/hugetlbfs/user/monad/pagesize-2MB/event-rings:/var/lib/hugetlbfs/user/monad/pagesize-2MB/event-rings:ro
16+
# Optional: Persistent logs volume
17+
- logs:/var/log/eventwatch
18+
restart: unless-stopped
19+
command: ["--server-addr", "0.0.0.0:8443"]
20+
logging:
21+
driver: json-file
22+
options:
23+
max-size: "10m"
24+
max-file: "3"
25+
26+
volumes:
27+
logs:

0 commit comments

Comments
 (0)