Skip to content

Commit

Permalink
enable running webapp in docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesamcl committed Nov 9, 2024
1 parent 9334180 commit c9ffc05
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 45 deletions.
77 changes: 45 additions & 32 deletions webapp/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,58 @@
services:
grebi-dataload:
build:
context: .
dockerfile: Dockerfile.dataload
grebi-ui:
image: ghcr.io/ebispot/grebi_ui:dev
ports:
- 8080:8080
environment:
- PUBLIC_URL=/
- REACT_APP_APIURL=http://localhost:8090
grebi-api:
image: ghcr.io/ebispot/grebi_api:dev
ports:
- 8090:8090
depends_on:
- grebi-neo4j
- grebi-solr
- grebi-resolver-service
- grebi-summary-service
links:
- grebi-neo4j
- grebi-solr
- grebi-resolver-service
- grebi-summary-service
environment:
- GREBI_NFS_TMP=/work/tmp
- GREBI_HPS_TMP=/work/tmp
- GREBI_CONFIG=${GREBI_CONFIG:?}
command: bash -c "cd /work && ./scripts/run_pipeline_local.sh"
- GREBI_NEO4J_HOST=bolt://grebi-neo4j:7687/
- GREBI_SOLR_HOST=http://grebi-solr:8983/
- GREBI_RESOLVER_HOST=http://grebi-resolver-service:8080/
- GREBI_SUMMARY_HOST=http://grebi-summary-service:8081/
grebi-neo4j:
image: neo4j:5.18.0
ports:
- 7474:7474
- 7687:7687
volumes:
- grebi-neo4j-data:/var/lib/neo4j/data
- ${GREBI_NEO_DATA_PATH:?Need path to Neo4j data folder}:/var/lib/neo4j/data
environment:
- NEO4J_AUTH=none
depends_on:
grebi-dataload:
condition: service_completed_successfully
# grebi-api:
# build: ./grebi_api
# ports:
# - 8080:8080
# environment:
# - GREBI_NEO4J_HOST=bolt://grebi-neo4j:7687
# depends_on:
# - grebi-neo4j
# links:
# - grebi-neo4j
# grebi-ui:
# build:
# context: ./grebi_ui
# #env_file: ./grebi_ui/.env
# ports:
# - 8081:8080
# depends_on:
# - grebi-api
# links:
# - grebi-api
- NEO4J_PLUGINS=["apoc"]
grebi-solr:
image: solr:9.5.0
ports:
- 8983:8983
volumes:
- ${GREBI_SOLR_PATH:?Need path to Solr data}:/var/solr/data
grebi-resolver-service:
image: ghcr.io/ebispot/grebi_resolver_service:dev
volumes:
- ${GREBI_ROCKSDB_SEARCH_PATH:?Need path to search for RocksDB databases}:/rocksdbs
environment:
- GREBI_ROCKSDB_SEARCH_PATH=/rocksdbs
grebi-summary-service:
image: ghcr.io/ebispot/grebi_summary_service:dev
volumes:
- ${GREBI_SUMMARY_JSON_SEARCH_PATH:?Need path to search for summary json files}:/summaryjsons
environment:
- GREBI_SUMMARY_JSON_SEARCH_PATH=/summaryjsons
volumes:
grebi-neo4j-data:

Expand Down
55 changes: 42 additions & 13 deletions webapp/grebi_api/src/main/java/uk/ac/ebi/grebi/GrebiApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,52 @@ public class GrebiApi {

public static void main(String[] args) throws ParseException, org.apache.commons.cli.ParseException, IOException {

final GrebiNeoRepo neo = new GrebiNeoRepo();
final GrebiSolrRepo solr = new GrebiSolrRepo();
final GrebiSummaryRepo summary = new GrebiSummaryRepo();
GrebiNeoRepo neo;
GrebiSolrRepo solr;
GrebiSummaryRepo summary;

Set<String> rocksDbSubgraphs = null;
Set<String> solrSubgraphs = null;
Set<String> summarySubgraphs = null;

while(true) {
try {
neo = new GrebiNeoRepo();
solr = new GrebiSolrRepo();
summary = new GrebiSummaryRepo();
rocksDbSubgraphs = (new ResolverClient()).getSubgraphs();
solrSubgraphs = solr.getSubgraphs();
summarySubgraphs = summary.getSubgraphs();
if(new HashSet<>(List.of(rocksDbSubgraphs, solrSubgraphs, summarySubgraphs)).size() != 1) {
throw new RuntimeException("RocksDB/Solr/the summary jsons do not seem to contain the same subgraphs. Found: " + String.join(",", rocksDbSubgraphs) + " for RocksDB (from resolver service) and " + String.join(",", solrSubgraphs) + " for Solr (from list of solr cores) and " + String.join(",", summarySubgraphs) + " for the summary jsons (from summary server)");
}
break;
} catch(Exception e) {
System.out.println("Could not get subgraphs from one of the services. Retrying in 10 seconds...");
e.printStackTrace();
try {
Thread.sleep(10000);
} catch (InterruptedException interruptedException) {
interruptedException.printStackTrace();
}
}
}

Gson gson = new Gson();
System.out.println("Found subgraphs: " + String.join(",", solrSubgraphs));

var stats = neo.getStats();
run(neo, solr, summary, solrSubgraphs);
}

var rocksDbSubgraphs = (new ResolverClient()).getSubgraphs();
var solrSubgraphs = solr.getSubgraphs();
var summarySubgraphs = summary.getSubgraphs();
static void run(
final GrebiNeoRepo neo,
final GrebiSolrRepo solr,
final GrebiSummaryRepo summary,
final Set<String> subgraphs
) {

if(new HashSet<>(List.of(rocksDbSubgraphs, solrSubgraphs, summarySubgraphs)).size() != 1) {
throw new RuntimeException("RocksDB/Solr/the summary jsons do not seem to contain the same subgraphs. Found: " + String.join(",", rocksDbSubgraphs) + " for RocksDB (from resolver service) and " + String.join(",", solrSubgraphs) + " for Solr (from list of solr cores) and " + String.join(",", summarySubgraphs) + " for the summary jsons (from summary server)");
}
var stats = neo.getStats();

System.out.println("Found subgraphs: " + String.join(",", solrSubgraphs));
Gson gson = new Gson();

Javalin.create(config -> {
config.bundledPlugins.enableCors(cors -> {
Expand All @@ -60,7 +89,7 @@ public static void main(String[] args) throws ParseException, org.apache.commons
})
.get("/api/v1/subgraphs", ctx -> {
ctx.contentType("application/json");
ctx.result(gson.toJson(solrSubgraphs));
ctx.result(gson.toJson(subgraphs));
})
.get("/api/v1/subgraphs/{subgraph}", ctx -> {
ctx.contentType("application/json");
Expand Down

0 comments on commit c9ffc05

Please sign in to comment.