From ab795d115ba82253f2c4e8778bb9ba93c3d02e94 Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 12 Dec 2024 16:33:49 -0500 Subject: [PATCH] devops: Add `api` to docker compose --- docker/Dockerfile | 25 ++++++++++++++++++++----- docker/docker-compose.yaml | 17 ++++++++++++++++- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index c09b239..2dbfe3a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,21 +4,27 @@ WORKDIR /kg-node COPY . . RUN apt-get update && apt-get upgrade -y RUN apt-get install libssl-dev protobuf-compiler -y -RUN cargo build --release --bin kg-node +RUN cargo build --release --bin indexer --bin api -FROM debian:bookworm-slim +# Run image +FROM debian:bookworm-slim AS run ENV neo4j_uri "" ENV neo4j_user "" ENV neo4j_pass "" -ENV SUBSTREAMS_API_TOKEN "" -ENV SUBSTREAMS_ENDPOINT_URL "" RUN apt-get update && apt-get upgrade -y RUN apt-get install -y libssl-dev +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ + +# Indexer image +FROM run AS indexer + +ENV SUBSTREAMS_API_TOKEN "" +ENV SUBSTREAMS_ENDPOINT_URL "" + COPY --from=builder /kg-node/target/release/kg-node . COPY --from=builder /kg-node/geo-substream.spkg . -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ CMD ./kg-node \ --reset-db \ @@ -26,3 +32,12 @@ CMD ./kg-node \ --neo4j-uri $neo4j_uri \ --neo4j-user $neo4j_user \ --neo4j-pass $neo4j_pass + +# GraphQL API image +FROM run AS api +COPY --from=builder /kg-node/target/release/api . + +CMD ./api \ + --neo4j-uri $neo4j_uri \ + --neo4j-user $neo4j_user \ + --neo4j-pass $neo4j_pass diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 4400ab9..36246da 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -15,7 +15,8 @@ services: timeout: 10s retries: 20 start_period: 3s - kg-node: + indexer: + image: indexer build: context: .. dockerfile: docker/Dockerfile @@ -28,3 +29,17 @@ services: neo4j_pass: neo4j SUBSTREAMS_API_TOKEN: ${SUBSTREAMS_API_TOKEN} SUBSTREAMS_ENDPOINT_URL: ${SUBSTREAMS_ENDPOINT_URL} + api: + image: api + build: + context: .. + dockerfile: docker/Dockerfile + ports: + - "8080:8080" + depends_on: + neo4j: + condition: service_healthy + environment: + neo4j_uri: neo4j://neo4j:7687 + neo4j_user: neo4j + neo4j_pass: neo4j