Skip to content

Commit

Permalink
update dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
makemake-kbo committed Jan 31, 2024
1 parent 49fd26a commit 33daae6
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
# Use an official Rust image as the base image
FROM rust:latest
# Use Rust official image for the build stage
FROM rust:latest AS build

# Set the working directory
WORKDIR /app
# Create and set the working directory
WORKDIR /usr/src/app

# Copy the Rust project to the working directory
COPY . .

# Install necessary dependencies for building the Rust project
RUN apt-get update && apt-get install -y libssl-dev pkg-config && \
# Clean up the apt cache to reduce image size
apt-get clean && rm -rf /var/lib/apt/lists/*

# Build the Rust project
# If your project uses a custom profile, replace `--release` with `--profile <your-profile>`
RUN RUSTFLAGS='-C target-cpu=native' cargo build --release

# Copy the project files into the container
COPY / /app
# Start a new stage to create a smaller final image
FROM debian:bookworm

# Install runtime dependencies
RUN apt-get update && apt-get install -y openssl ca-certificates && \
# Clean up the apt cache to reduce image size
apt-get clean && rm -rf /var/lib/apt/lists/*

# Create a directory for the application
WORKDIR /app

# Install libssl-dev
RUN apt-get update && apt-get install -y libssl-dev
# Copy the built binary from the build stage to the application directory
COPY --from=build /usr/src/app/target/release/blutgang /app/blutgang

# Build and run the Rust project
CMD ["cargo", "run", "--profile", "maxperf", "--", "-c", "config.toml"]
# Set the command to run the application
CMD ["./blutgang", "-c", "config.toml"]

0 comments on commit 33daae6

Please sign in to comment.