Skip to content
Snippets Groups Projects
Verified Commit 8104c88a authored by Antoine R. Dumont's avatar Antoine R. Dumont
Browse files

graph: Decrease image size

Build the swh-graph-grpc-serve binary and only copy the result into the
destination image.

This splits the final image size to ~500Mo instead of ~1Go.

Refs. swh/infra/sysadm-environment#5382
parent 5694a78d
No related branches found
Tags swh-web-20240829.1
No related merge requests found
# Deeply inspired from the Dockerfile of the swh-graphql project
FROM rust:1.80-bookworm
FROM rust:1.80-bookworm AS rust_build
# ... build swh-graph rust deps
RUN apt-get -y update && \
apt-get -y upgrade && \
apt-get install -y build-essential libclang-dev \
zstd protobuf-compiler default-jre && \
apt clean
# Install swh-graph feature swh-graph-grpc-serve
# TODO: Ensure the target-cpu is ok
RUN RUSTFLAGS="-C target-cpu=native" \
cargo install \
--features grpc-server \
swh-graph
FROM python:3.10-bookworm
ARG UID=1000
ARG GID=1000
RUN apt-get -y update && \
apt-get -y upgrade && \
apt-get install -y python3 python3-pip \
libcmph-dev librdkafka-dev \
build-essential libclang-dev \
zstd protobuf-compiler default-jre && \
apt-get install -y python3-pip \
libcmph-dev librdkafka-dev && \
apt clean && \
addgroup --gid $UID swh && \
useradd --gid $GID --uid $UID -m -d /opt/swh swh && \
......@@ -25,13 +38,7 @@ ENV PATH=/opt/swh/.local/bin:$PATH
RUN /usr/bin/python3 -m pip install --upgrade pip --break-system-packages && \
pip install --no-cache-dir -r requirements-frozen.txt --break-system-packages
# Install
RUN RUSTFLAGS="-C target-cpu=native" \
cargo install \
--features grpc-server \
swh-graph
COPY --from=rust_build /usr/local/cargo/bin/swh-graph-* /usr/local/bin/
ENV SWH_CONFIG_FILENAME=/etc/swh/config.yml
ENV PORT 5009
EXPOSE $PORT
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment