sanbo110 commited on
Commit
780e76c
·
1 Parent(s): 833c5b4

update sth at 2025-10-12 18:22:54

Browse files
Files changed (2) hide show
  1. Dockerfile +8 -9
  2. Dockerfile.simple +0 -32
Dockerfile CHANGED
@@ -11,18 +11,17 @@ RUN apk add --no-cache \
11
  # Set working directory
12
  WORKDIR /app
13
 
14
- # Copy all source files first
15
- COPY . .
16
 
17
- # Create dummy main file for dependency caching
18
- RUN mkdir -p src/bin && echo "fn main() {}" > src/bin/api_server.rs
19
 
20
- # Build dependencies first (this will be cached if dependencies don't change)
21
- RUN cargo build --release --bin api_server
22
 
23
- # Clean and rebuild with actual source
24
- RUN rm -rf src/bin/api_server.rs && \
25
- cargo build --release --bin api_server
26
 
27
  # Final runtime stage
28
  FROM alpine:3.20
 
11
  # Set working directory
12
  WORKDIR /app
13
 
14
+ # Copy manifest files first
15
+ COPY Cargo.toml Cargo.lock ./
16
 
17
+ # Create src directory structure
18
+ RUN mkdir -p src
19
 
20
+ # Copy the actual source files (including api_server.rs)
21
+ COPY src ./src
22
 
23
+ # Build the application
24
+ RUN cargo build --release --bin api_server
 
25
 
26
  # Final runtime stage
27
  FROM alpine:3.20
Dockerfile.simple DELETED
@@ -1,32 +0,0 @@
1
- # Simple single-stage build for debugging
2
- FROM rust:1.90-alpine
3
-
4
- # Install build and runtime dependencies
5
- RUN apk add --no-cache \
6
- musl-dev \
7
- pkgconfig \
8
- openssl-dev \
9
- openssl-libs-static \
10
- ca-certificates
11
-
12
- # Set working directory
13
- WORKDIR /app
14
-
15
- # Copy source code first
16
- COPY . .
17
-
18
- # Verify files exist
19
- RUN ls -la src/bin/ && \
20
- echo "Checking if api_server.rs exists..." && \
21
- test -f src/bin/api_server.rs || echo "api_server.rs not found!"
22
-
23
- # Expose the default port
24
- EXPOSE 7860
25
-
26
- # Set environment variables
27
- ENV RUST_LOG=info
28
- ENV API_HOST=0.0.0.0
29
- ENV API_PORT=7860
30
-
31
- # Run the application directly
32
- CMD ["cargo", "run", "--bin", "api_server", "--", "--no-proxy"]