Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Containerize apollo router for compound soaking
Browse files Browse the repository at this point in the history
  • Loading branch information
iamvigneshwars committed Feb 29, 2024
1 parent 78deea6 commit f44adee
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 27 deletions.
5 changes: 2 additions & 3 deletions .devcontainer/Dockerfile.backend
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ RUN apt-get update \
libopencv-dev clang libclang-dev \
&& rm -rf /var/lib/apt/lists/*

# Install Rover CLI for composing and precompiles rust router (gateway) for subgraphs
RUN curl -sSL https://rover.apollo.dev/nix/latest | sh\
&& curl -sSL https://router.apollo.dev/download/nix/latest | sh
# Install Rover CLI for composing subgraphs
RUN curl -sSL https://rover.apollo.dev/nix/latest | sh
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
}
},
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"ghcr.io/devcontainers/features/common-utils:2.3.0": {
"username": "none",
"upgradePackages": false
},
"ghcr.io/devcontainers/features/git-lfs:1": {}
"ghcr.io/devcontainers/features/git-lfs:1.1.0": {}
},
"runArgs": [
"--security-opt=label=type:container_runtime_t"
Expand Down
17 changes: 17 additions & 0 deletions .devcontainer/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
version: "3.8"

services:
apollo-router:
image: ghcr.io/apollographql/router:v1.41.0-rc.2
volumes:
- ./supergraph.graphql:/dist/schema/supergraph.graphql
- ./router.yaml:/dist/config/router.yaml
ports:
- 4001:4000
command:
- --dev
- -config
- config/router.yaml
- -supergraph
- schema/supergraph.graphql

backend:
build:
context: .
Expand All @@ -12,6 +26,9 @@ services:
OPA_URL: http://opa:8181
DATABASE_URL: postgres://postgres:password@postgres
RABBITMQ_URL: amqp://rabbitmq:password@rabbitmq
CRYSTAL_LIBRARY_PORT: 8000
COMPOUND_LIBRARY_PORT: 8001
COMPOUND_SOAKING_PORT: 8002

frontend:
image: docker.io/library/node:20.6.0-bookworm
Expand Down
5 changes: 4 additions & 1 deletion backend/router.yaml → .devcontainer/router.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
supergraph:
listen: 0.0.0.0:4000
headers:
all: # Header rules for all subgraphs
request:
- propagate:
matching: .*
matching: .*

5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@
# Developer Tooling
.vscode

# Apollo router
router
backend/router
# Generated supergraph schema
backend/supergraph.graphql
.devcontainer/supergraph.graphql
4 changes: 2 additions & 2 deletions backend/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
}
},
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"ghcr.io/devcontainers/features/common-utils:2.3.0": {
"username": "none",
"upgradePackages": false
},
"ghcr.io/devcontainers/features/git-lfs:1": {}
"ghcr.io/devcontainers/features/git-lfs:1.1.0": {}
},
// Make sure the files we are mapping into the container exist on the host
"initializeCommand": "bash -c 'for i in $HOME/.inputrc; do [ -f $i ] || touch $i; done'",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl CompoundInstanceQuery {

/// Reference resolver for compound instance in compound library subgraph
#[graphql(entity)]
async fn get_compound_instance_by_id(
async fn route_compound_instance(
&self,
ctx: &Context<'_>,
plate_id: Uuid,
Expand Down
2 changes: 1 addition & 1 deletion backend/compound_library/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ enum Cli {
#[allow(clippy::missing_docs_in_private_items)]
struct ServeArgs {
/// The port number to serve on.
#[arg(short, long, default_value_t = 80)]
#[arg(short, long, default_value_t = 80, env = "COMPOUND_LIBRARY_PORT")]
port: u16,
/// URL for the OPA server
#[arg(long, env)]
Expand Down
6 changes: 3 additions & 3 deletions backend/compound_soaking/src/graphql/soak_compound_res.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl SoakCompoundQuery {

/// Reference resolver for crystal wells
#[graphql(entity)]
async fn get_crystal_well_by_plate_id(&self, plate_id: Uuid, well_number: i16) -> CrystalWells {
async fn route_crystal_well(&self, plate_id: Uuid, well_number: i16) -> CrystalWells {
CrystalWells {
plate_id,
well_number,
Expand All @@ -116,7 +116,7 @@ impl SoakCompoundQuery {

/// Reference resolver for compound wells
#[graphql(entity)]
async fn get_compound_instances_by_plate_id(
async fn route_compound_instances(
&self,
plate_id: Uuid,
well_number: i16,
Expand All @@ -131,7 +131,7 @@ impl SoakCompoundQuery {
#[Object]
impl SoakCompoundMutation {
/// Adds a soaked compound to the database
async fn add_soaked_compound(
async fn soak_compound(
&self,
ctx: &Context<'_>,
compound_plate_id: Uuid,
Expand Down
2 changes: 1 addition & 1 deletion backend/compound_soaking/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ enum Cli {
#[derive(Debug, Parser)]
#[allow(clippy::missing_docs_in_private_items)]
struct ServeArgs {
#[arg(short, long, default_value_t = 80)]
#[arg(short, long, default_value_t = 80, env = "COMPOUND_SOAKING_PORT")]
port: u16,
#[arg(long, env)]
database_url: Url,
Expand Down
2 changes: 1 addition & 1 deletion backend/compound_soaking/src/tables/soak_compound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct Model {
/// The well on the plate which the crystal is located.
#[sea_orm(primary_key, auto_increment = false)]
pub crystal_well_number: i16,
/// The volume of compounds soaked.
/// The volume of compounds transferred into the crystal well.
pub volume: f32,
/// The identifier of the operator which added this entry.
pub operator_id: String,
Expand Down
2 changes: 1 addition & 1 deletion backend/crystal_library/src/graphql/crystal_wells_res.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl CrystalWellsQuery {

/// Reference resolver for crystal wells in crystal library graphql subgraph
#[graphql(entity)]
async fn find_crystal_wells_by_id(
async fn route_crystal_wells(
&self,
ctx: &Context<'_>,
plate_id: Uuid,
Expand Down
2 changes: 1 addition & 1 deletion backend/crystal_library/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ enum Cli {
#[allow(clippy::missing_docs_in_private_items)]
struct ServeArgs {
/// The port number to serve on
#[arg(short, long, default_value_t = 80)]
#[arg(short, long, default_value_t = 80, env = "CRYSTAL_LIBRARY_PORT")]
port: u16,
/// URL for the database
#[arg(long, env)]
Expand Down
13 changes: 7 additions & 6 deletions backend/supergraph-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
federation_version: 2
subgraphs:
crystal_library:
routing_url: http://localhost:80
routing_url: http://backend:8000
schema:
subgraph_url: http://localhost:80
subgraph_url: http://backend:8000
compound_library:
routing_url: http://localhost:81
routing_url: http://backend:8001
schema:
subgraph_url: http://localhost:81
subgraph_url: http://backend:8001
compound_soaking:
routing_url: http://localhost:82
routing_url: http://backend:8002
schema:
subgraph_url: http://localhost:82
subgraph_url: http://backend:8002

0 comments on commit f44adee

Please sign in to comment.