-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
35 lines (25 loc) · 855 Bytes
/
Dockerfile
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
# Use the official Rust image as the base image
FROM rust:latest as builder
# Set the working directory
WORKDIR /app
# Copy the Cargo.toml and Cargo.lock files to leverage Docker layer caching
COPY ./Cargo.toml ./Cargo.lock ./
# Build a minimal Rust project to cache dependencies
RUN mkdir src && \
echo "fn main() {println!(\"dummy\")}" > src/main.rs && \
cargo build --release && \
rm -rf src target
# Copy the entire source code
COPY ./ .
# Build the actual Rust application
RUN cargo build --release
# Create a new image from a smaller base image
FROM debian:buster-slim
# Set the working directory
WORKDIR /app
# Copy only the built binary from the previous stage
COPY --from=builder /app/target/release/game_of_life .
# Expose any necessary ports
EXPOSE 8080
# Define the command to run your application
CMD ["./game_of_life"]