Skip to content

Commit

Permalink
fix: Fix agora-mongo:prepare (Sage-Bionetworks#2103)
Browse files Browse the repository at this point in the history
* Create agora space in docker/

* Fix docker

* One more improvement
  • Loading branch information
tschaffter authored Sep 8, 2023
1 parent 884bce4 commit a2e9eef
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 39 deletions.
7 changes: 6 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
3306,
4200,
4211,
5017,
5200,
5432,
5601,
Expand Down Expand Up @@ -120,8 +121,12 @@
"label": "openchallenges-postgres",
"onAutoForward": "silent"
},
"5017": {
"label": "agora-mongo",
"onAutoForward": "silent"
},
"5200": {
"label": "agora-webapp",
"label": "agora-web-app",
"onAutoForward": "silent"
},
"5601": {
Expand Down
2 changes: 1 addition & 1 deletion apps/agora/mongo/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
MONGO_INITDB_ROOT_USERNAME=root
MONGO_INITDB_ROOT_PASSWORD=changeme
MONGO_INITDB_DATABASE=challenge
MONGO_INITDB_DATABASE=agora
23 changes: 0 additions & 23 deletions apps/agora/mongo/docker-compose.yml

This file was deleted.

56 changes: 45 additions & 11 deletions apps/agora/mongo/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,65 @@
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/agora/mongo/src",
"projectType": "application",
"tags": ["type:db", "scope:backend"],
"targets": {
"prepare": {
"create-config": {
"executor": "nx:run-commands",
"options": {
"command": "shx cp -n .env.example .env",
"cwd": "apps/agora/mongo"
"command": "cp -n .env.example .env",
"cwd": "{projectRoot}"
}
},
"serve": {
"serve-detach": {
"executor": "nx:run-commands",
"options": {
"command": "docker compose up",
"cwd": "apps/agora/mongo"
},
"dependsOn": []
"command": "docker/agora/serve-detach.sh {projectName}"
}
},
"build-image": {
"executor": "@nx-tools/nx-container:build",
"options": {
"context": "apps/agora/mongo",
"push": false,
"tags": ["ghcr.io/sage-bionetworks/agora-mongo:local"]
"metadata": {
"images": ["ghcr.io/sage-bionetworks/{projectName}"],
"tags": ["type=edge,branch=main", "type=raw,value=local", "type=sha"]
},
"push": false
}
},
"publish-image": {
"executor": "@nx-tools/nx-container:build",
"options": {
"context": "apps/agora/mongo",
"metadata": {
"images": ["ghcr.io/sage-bionetworks/{projectName}"],
"tags": ["type=edge,branch=main", "type=sha"]
},
"push": true
},
"dependsOn": ["build-image"]
},
"publish-and-remove-image": {
"executor": "nx:run-commands",
"options": {
"command": "docker rmi $(docker images --filter=reference=ghcr.io/sage-bionetworks/{projectName}:* --quiet) --force"
},
"dependsOn": ["publish-image"]
},
"build-and-remove-image": {
"executor": "nx:run-commands",
"options": {
"command": "docker rmi $(docker images --filter=reference=ghcr.io/sage-bionetworks/{projectName}:* --quiet) --force"
},
"dependsOn": ["build-image"]
},
"scan-image": {
"executor": "nx:run-commands",
"options": {
"command": "trivy image ghcr.io/sage-bionetworks/{projectName}:local --quiet",
"color": true
}
}
},
"tags": ["type:db", "scope:backend"],
"implicitDependencies": []
}
2 changes: 1 addition & 1 deletion apps/agora/webapp/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"projectType": "application",
"prefix": "sagebionetworks",
"sourceRoot": "apps/agora/webapp/src",
"tags": [],
"tags": ["language:typescript"],
"targets": {
"build": {
"executor": "@angular-devkit/build-angular:browser",
Expand Down
3 changes: 1 addition & 2 deletions apps/openchallenges/mariadb/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"executor": "nx:run-commands",
"options": {
"command": "docker/openchallenges/serve-detach.sh openchallenges-mariadb"
},
"dependsOn": []
}
},
"build-image": {
"executor": "@nx-tools/nx-container:build",
Expand Down
6 changes: 6 additions & 0 deletions docker/agora/networks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: '3.8'

networks:
agora:
name: agora
driver: bridge
14 changes: 14 additions & 0 deletions docker/agora/serve-detach.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

args=(
# List of services in alphanumeric order
--file docker/agora/services/mongo.yml
# --file docker/agora/services/web-app.yml

--file docker/agora/networks.yml
--file docker/agora/volumes.yml

up $1 --detach --remove-orphans
)

docker compose "${args[@]}"
19 changes: 19 additions & 0 deletions docker/agora/services/mongo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: '3.8'

services:
agora-mongo:
image: ghcr.io/sage-bionetworks/agora-mongo:${AGORA_VERSION:-local}
container_name: agora-mongo
restart: always
env_file:
- ../../../apps/agora/mongo/.env
volumes:
- agora-mongo-data:/data/db
networks:
- agora
ports:
- '5017:27017'
deploy:
resources:
limits:
memory: 500M
20 changes: 20 additions & 0 deletions docker/agora/services/web-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '3.8'

services:
agora-web-app:
image: ghcr.io/sage-bionetworks/agora-web-app:${AGORA_VERSION:-local}
container_name: agora-web-app
restart: always
networks:
- agora
ports:
- '5200:5200'
env_file:
- ../../../apps/agora/web-app/.env
deploy:
resources:
limits:
memory: 200M
depends_on:
agora-mongo:
condition: service_started
5 changes: 5 additions & 0 deletions docker/agora/volumes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: '3.8'

volumes:
agora-mongo-data:
name: agora-mongo-data

0 comments on commit a2e9eef

Please sign in to comment.