Skip to content

Commit 3750b3e

Browse files
committed
Update the loading files of the backend
1 parent 669ae70 commit 3750b3e

105 files changed

Lines changed: 668 additions & 302 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

backend/.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
target/
2+
.git/
3+
.gitignore
4+
*.md
5+
BUILD_TROUBLESHOOTING.md
6+
DEPLOYMENT.md
7+
.env
8+
.env.local
9+

backend/.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Rust
2+
/target/
3+
**/*.rs.bk
4+
Cargo.lock
5+
6+
# IDE
7+
.idea/
8+
.vscode/
9+
*.swp
10+
*.swo
11+
*~
12+
13+
# OS
14+
.DS_Store
15+
Thumbs.db
16+

backend/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "rust-backend"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
axum = "0.7"
8+
tower = "0.4"
9+
tower-http = { version = "0.5", features = ["cors"] }
10+
serde = { version = "1.0", features = ["derive"] }
11+
serde_json = "1.0"
12+
tokio = { version = "1.35", features = ["full"] }
13+
anyhow = "1.0"
14+
thiserror = "1.0"

backend/Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Multi-stage build for Rust backend
2+
3+
# Build stage
4+
FROM rust:1.75 as builder
5+
WORKDIR /app
6+
7+
# Copy dependency files first (for better caching)
8+
COPY backend/Cargo.toml backend/Cargo.lock ./
9+
RUN mkdir src && echo "fn main() {}" > src/main.rs
10+
RUN cargo build --release
11+
RUN rm src/main.rs
12+
13+
# Copy source code
14+
COPY backend/src ./src
15+
COPY backend/data ./data
16+
17+
# Build the actual application
18+
RUN touch src/main.rs && cargo build --release
19+
20+
# Runtime stage
21+
FROM debian:bookworm-slim
22+
23+
# Install CA certificates for HTTPS
24+
RUN apt-get update && apt-get install -y \
25+
ca-certificates \
26+
&& rm -rf /var/lib/apt/lists/*
27+
28+
WORKDIR /app
29+
30+
# Copy the binary from builder
31+
COPY --from=builder /app/target/release/rust-backend /app/rust-backend
32+
33+
# Copy data directory
34+
COPY --from=builder /app/data ./data
35+
36+
# Set environment variables
37+
ENV PORT=8080
38+
EXPOSE 8080
39+
40+
# Run the application
41+
CMD ["./rust-backend"]
42+

backend/README.md

Lines changed: 119 additions & 0 deletions
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)