From 36d5be4300681807a9858a0e63469a072dba9d3b Mon Sep 17 00:00:00 2001 From: DhananjayPurohit Date: Fri, 24 May 2024 17:43:39 +0530 Subject: [PATCH] fix: mercury server dockerfile --- server/Dockerfile | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/server/Dockerfile b/server/Dockerfile index 70ba0c62..b43a39b1 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -1,14 +1,33 @@ -FROM rust:1.77.0 +# Use a base image that has the required GLIBC version +FROM debian:bullseye-slim as builder -# Set working directory -WORKDIR /app/lib -COPY ../lib . +# Install Rust, protobuf compiler, and library dependencies +RUN apt-get update && apt-get install -y curl build-essential protobuf-compiler libprotobuf-dev pkg-config libssl-dev +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y -# Copy the project code -WORKDIR /app -COPY . . +# Set the environment path for Rust +ENV PATH="/root/.cargo/bin:${PATH}" -RUN cargo build --release -EXPOSE 8000 -# Run the application +# Create a working directory +WORKDIR /mercurylayer + +RUN echo "[workspace]\nmembers = [\"server\", \"lib\"]" > ./Cargo.toml +COPY ./Cargo.lock ./Cargo.lock + +# Copy the server source code +COPY ./server ./server +COPY ./lib ./lib + +# Make sure to copy Cargo.lock +COPY ./server/Cargo.lock ./server/Cargo.lock + +WORKDIR /mercurylayer/server + +# RUN cargo build --verbose + +# # Build your Rust project. Since the source files are now present, +# # the Rust compiler should be able to find and compile them. +RUN CARGO_TARGET_DIR=target cargo build --release + +# # Command to run the server by default when the container starts CMD ["cargo", "run", "--bin", "mercury-server"]