Skip to content

Commit

Permalink
Merge branch 'main' into dboreham/test-database-stack
Browse files Browse the repository at this point in the history
  • Loading branch information
dboreham committed Feb 12, 2024
2 parents 4a116d0 + c944459 commit c36f1e4
Show file tree
Hide file tree
Showing 14 changed files with 127 additions and 8 deletions.
20 changes: 20 additions & 0 deletions stack_orchestrator/data/compose/docker-compose-mars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: "3.2"

services:
mars:
image: cerc/mars:local
restart: always
ports:
- "3000:3000"
environment:
- URL_OSMOSIS_GQL=https://osmosis-node.marsprotocol.io/GGSFGSFGFG34/osmosis-hive-front/graphql
- URL_OSMOSIS_REST=https://lcd-osmosis.blockapsis.com
- URL_OSMOSIS_RPC=https://rpc-osmosis.blockapsis.com
- URL_NEUTRON_GQL=https://neutron.rpc.p2p.world/qgrnU6PsQZA8F9S5Fb8Fn3tV3kXmMBl2M9bcc9jWLjQy8p/hive/graphql
- URL_NEUTRON_REST=https://rest-kralum.neutron-1.neutron.org
- URL_NEUTRON_RPC=https://rpc-kralum.neutron-1.neutron.org
- URL_NEUTRON_TEST_GQL=https://testnet-neutron-gql.marsprotocol.io/graphql
- URL_NEUTRON_TEST_REST=https://rest-palvus.pion-1.ntrn.tech
- URL_NEUTRON_TEST_RPC=https://rpc-palvus.pion-1.ntrn.tech
- WALLET_CONNECT_ID=0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x

8 changes: 8 additions & 0 deletions stack_orchestrator/data/compose/docker-compose-ping-pub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "3.2"

services:
ping-pub:
image: cerc/ping-pub:local
restart: always
ports:
- "5173:5173"
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ services:
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
ports:
- "3000"
- "80"
4 changes: 4 additions & 0 deletions stack_orchestrator/data/container-build/cerc-mars/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
# Build the mars image
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
docker build -t cerc/mars:local -f ${CERC_REPO_BASE_DIR}/mars-interface/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/mars-interface
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
# Build the ping pub image
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh

docker build -t cerc/ping-pub:local ${build_command_args} -f $CERC_REPO_BASE_DIR/explorer/Dockerfile $CERC_REPO_BASE_DIR/explorer
16 changes: 16 additions & 0 deletions stack_orchestrator/data/stacks/mars/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# mars

On a fresh Digital Ocean droplet with Ubuntu:

```
git clone https://github.com/cerc-io/stack-orchestrator
cd stack-orchestrator
./scripts/quick-install-linux.sh
```
Read and follow the instructions output from the above output to complete installation, then:

```
laconic-so --stack mars setup-repositories
laconic-so --stack mars build-containers
laconic-so --stack mars deploy up
```
8 changes: 8 additions & 0 deletions stack_orchestrator/data/stacks/mars/stack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "0.1"
name: mars
repos:
- github.com/cerc-io/mars-interface
containers:
- cerc/mars
pods:
- mars
10 changes: 10 additions & 0 deletions stack_orchestrator/data/stacks/ping-pub/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ping-pub
Experimental block explorer for laconic

```
laconic-so --stack ping-pub setup-repositories
laconic-so --stack ping-pub build-containers
laconic-so --stack ping-pub deploy init --output ping-pub-spec.yml --map-ports-to-host localhost-same
laconic-so --stack ping-pub deploy create --spec-file ping-pub-spec.yml --deployment-dir pp-deployment
laconic-so deployment --dir pp-deployment start
```
9 changes: 9 additions & 0 deletions stack_orchestrator/data/stacks/ping-pub/stack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: "0.1"
name: ping-pub
repos:
# fork, but only for config & Dockerfile reasonsb
- github.com/LaconicNetwork/explorer@laconic
containers:
- cerc/ping-pub
pods:
- ping-pub
28 changes: 26 additions & 2 deletions stack_orchestrator/deploy/k8s/cluster_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def get_deployment(self, image_pull_policy: str = None):
merged_envs = merge_envs(
envs_from_compose_file(
service_info["environment"]), self.environment_variables.map
) if "environment" in service_info else self.environment_variables.map
) if "environment" in service_info else self.environment_variables.map
envs = envs_from_environment_variables_map(merged_envs)
if opts.o.debug:
print(f"Merged envs: {envs}")
Expand All @@ -281,13 +281,37 @@ def get_deployment(self, image_pull_policy: str = None):
env=envs,
ports=[client.V1ContainerPort(container_port=port)],
volume_mounts=volume_mounts,
security_context=client.V1SecurityContext(
privileged=self.spec.get_privileged(),
capabilities=client.V1Capabilities(
add=self.spec.get_capabilities()
) if self.spec.get_capabilities() else None
),
resources=to_k8s_resource_requirements(resources),
)
containers.append(container)
volumes = volumes_for_pod_files(self.parsed_pod_yaml_map, self.spec, self.app_name)
image_pull_secrets = [client.V1LocalObjectReference(name="laconic-registry")]

annotations = None
labels = {"app": self.app_name}

if self.spec.get_annotations():
annotations = {}
for key, value in self.spec.get_annotations().items():
for service_name in services:
annotations[key.replace("{name}", service_name)] = value

if self.spec.get_labels():
for key, value in self.spec.get_labels().items():
for service_name in services:
labels[key.replace("{name}", service_name)] = value

template = client.V1PodTemplateSpec(
metadata=client.V1ObjectMeta(labels={"app": self.app_name}),
metadata=client.V1ObjectMeta(
annotations=annotations,
labels=labels
),
spec=client.V1PodSpec(containers=containers, image_pull_secrets=image_pull_secrets, volumes=volumes),
)
spec = client.V1DeploymentSpec(
Expand Down
12 changes: 12 additions & 0 deletions stack_orchestrator/deploy/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,15 @@ def get_http_proxy(self):
if self.obj and constants.network_key in self.obj
and constants.http_proxy_key in self.obj[constants.network_key]
else None)

def get_annotations(self):
return self.obj.get("annotations", {})

def get_labels(self):
return self.obj.get("labels", {})

def get_privileged(self):
return "true" == str(self.obj.get("security", {}).get("privileged", "false")).lower()

def get_capabilities(self):
return self.obj.get("security", {}).get("capabilities", [])
2 changes: 1 addition & 1 deletion stack_orchestrator/deploy/webapp/deploy_webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _fixup_url_spec(spec_file_name: str, url: str):
- host-name: {parsed_url.hostname}
routes:
- path: '{parsed_url.path if parsed_url.path else "/"}'
proxy-to: webapp:3000
proxy-to: webapp:80
'''
spec_file_path = Path(spec_file_name)
with open(spec_file_path) as rfile:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def command(ctx, laconic_config, deployment_parent_dir,

previous_requests = load_known_requests(state_file)
requests.sort(key=lambda r: r.createTime)
requests.reverse()

# Find deployments.
deployments = {}
Expand Down
10 changes: 6 additions & 4 deletions stack_orchestrator/deploy/webapp/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,13 @@ def generate_hostname_for_app(app):

def skip_by_tag(r, include_tags, exclude_tags):
for tag in exclude_tags:
if tag and r.attributes.tags and tag in r.attributes.tags:
if r.attributes.tags and tag in r.attributes.tags:
return True

for tag in include_tags:
if tag and (not r.attributes.tags or tag not in r.attributes.tags):
return True
if include_tags:
for tag in include_tags:
if r.attributes.tags and tag in r.attributes.tags:
return False
return True

return False

0 comments on commit c36f1e4

Please sign in to comment.