Skip to content

Commit

Permalink
CELE-18 Add scripts for CI deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
aranega committed Apr 20, 2024
1 parent 1ab4cc4 commit 9c11ec6
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
skaffold.yaml
docker-compose.yaml
docker-compose.yaml
# deployment/
cloud-harness/
.vscode/
8 changes: 7 additions & 1 deletion applications/visualizer/generate-binding.bash
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
#!/usr/bin/env bash

OPENAPI_FOLDER="openapi/openapi.json"
OPENAPI_JSON="openapi.json"
OPENAPI_YAML="openapi.yaml"
OPENAPI_FOLDER="openapi/${OPENAPI_JSON}"

# Trick to have folder relative to the script, not CWD
PARENT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "${PARENT_PATH}"

function json2yaml {
python -c 'import sys, yaml, json; print(yaml.dump(json.loads(sys.stdin.read())))'
}

# Generates the openAPI specification
(cd backend && DJANGO_EXTRA_APPS="ninja" python manage.py export_openapi_schema --output "${OPENAPI_FOLDER}" --indent 2)
cp backend/"${OPENAPI_FOLDER}" api/
cat api/"${OPENAPI_JSON}" | json2yaml > api/"${OPENAPI_YAML}"

# Generates the typescript API binding
(cd frontend && npm run generate-client)
53 changes: 45 additions & 8 deletions dev-install.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from subprocess import run
import os
from pathlib import Path
import sys

Expand Down Expand Up @@ -39,6 +38,7 @@ def __getitem__(self, keys):
self.args.append(keys)
return self


sh = Command()


Expand All @@ -48,33 +48,67 @@ def in_venv():

def check_venv_activate():
if not in_venv():
print("You are not in a virtualenv, please initialise and activate a python 3.11 venv before running this script")
print(
"You are not in a virtualenv, please initialise and activate a python 3.11 venv before running this script"
)
sys.exit(1)


def install_cloud_harness():
if not Path("cloud-harness").exists():
print("Cloning cloud-harness branch CH-100 (experimental docker compose support)")
sh.git.clone("--single-branch", "--branch", "feature/CH-100", "https://github.com/MetaCell/cloud-harness.git")
print(
"Cloning cloud-harness branch CH-100 (experimental docker compose support)"
)
sh.git.clone(
"--single-branch",
"--branch",
"feature/CH-100",
"https://github.com/MetaCell/cloud-harness.git",
)

print("Installing cloud-harness")
sh.bash("cloud-harness/install.sh")


def generate_dev_deployment():
# fmt: off
def generate_local_dev_deployment():
# harness-deployment cloud-harness . -l -d javelin.local -dtls -n javelin -e local -i dashboard
sh("harness-deployment",
"cloud-harness", ".",
"-l",
"-d", "celegans.local",
"-dtls",
"-n", "celegans",
"-e", "local",
"-e", "dev",
"-i", "visualizer",
"--docker-compose"
)


def generate_dev_deployment():
# harness-deployment cloud-harness . -l -d javelin.local -dtls -n javelin -e local -i dashboard
sh("harness-deployment",
"cloud-harness", ".",
"-n", "celegans",
"-e", "dev",
"-i", "visualizer",
"--docker-compose"
)



def generate_prod_deployment():
# harness-deployment cloud-harness . -l -d javelin.local -dtls -n javelin -e local -i dashboard
sh("harness-deployment",
"cloud-harness", ".",
"-n", "celegans",
"-e", "prod",
"-i", "visualizer",
"--docker-compose"
)
# fmt: on


def install_backend_dependencies():
sh.pip.install("-r", APP_FOLDER / "backend" / "requirements.txt")
sh.pip.install("-r", APP_FOLDER / "backend" / "requirements-dev.txt")
Expand All @@ -87,6 +121,9 @@ def install_frontend_dependencies():
if __name__ == "__main__":
check_venv_activate()
install_cloud_harness()
generate_dev_deployment()
generate_local_dev_deployment
# generate_dev_deployment()
# generate_prod_deployment()

install_backend_dependencies()
install_frontend_dependencies()
install_frontend_dependencies()

0 comments on commit 9c11ec6

Please sign in to comment.