Skip to content

Commit

Permalink
Fix existing rust Dockerfile (#1844)
Browse files Browse the repository at this point in the history
* fix existing rust Dockerfile

* fmt

---------

Co-authored-by: Shivam Kapoor <[email protected]>
Co-authored-by: Shivam <[email protected]>
  • Loading branch information
3 people authored Nov 6, 2024
1 parent a520c65 commit 82607f4
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 182 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ members = [
"raphtory-graphql",
"raphtory-api",
]
default-members = ["raphtory"]
default-members = ["raphtory", "raphtory-graphql"]
resolver = "2"

[workspace.package]
Expand Down
61 changes: 23 additions & 38 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,40 +1,25 @@
FROM rust:1.77 AS builder

WORKDIR /app

COPY Cargo.toml Cargo.lock ./
RUN sed -i '/default-members/d' Cargo.toml
RUN sed -i '/members = \[/,/\]/c\members = ["raphtory", "raphtory-graphql"]' Cargo.toml

WORKDIR /app/raphtory
COPY raphtory/Cargo.toml ./
RUN mkdir src && echo "fn main() {}" > src/main.rs

WORKDIR /app/raphtory-graphql
COPY raphtory-graphql/Cargo.toml ./
RUN mkdir src && echo "fn main() {}" > src/main.rs

FROM rust:1.80.0 AS chef
RUN cargo install cargo-chef --version 0.1.67
WORKDIR /app
RUN cargo build --release --workspace

COPY raphtory ./raphtory
COPY raphtory-graphql ./raphtory-graphql

WORKDIR /app/raphtory-graphql
RUN cargo build --release

FROM rust:1.77-slim AS runner

WORKDIR /app

RUN groupadd -g 999 appuser && \
useradd -r -u 999 -g appuser appuser
USER appuser

COPY --from=builder /app/target/release/raphtory-graphql /app

EXPOSE 1736

ENV GRAPH_DIRECTORY=graphs

CMD ["./raphtory-graphql"]
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json

FROM chef AS builder
RUN apt-get update
RUN apt-get install -y protobuf-compiler
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
# RUN cargo chef cook --recipe-path recipe.json
COPY . .
RUN cargo build --release -p raphtory-graphql
# RUN cargo build -p raphtory-graphql

# FROM alpine:3.20.3
FROM debian:bookworm-slim
ENV PORT=1736
COPY --from=builder /app/target/release/raphtory-graphql /raphtory-graphql
# COPY --from=builder /app/target/debug/raphtory-graphql /usr/local/bin/raphtory-graphql
WORKDIR /graphs
CMD ["/raphtory-graphql"]
Loading

0 comments on commit 82607f4

Please sign in to comment.