Skip to content

Commit

Permalink
fix: volume
Browse files Browse the repository at this point in the history
  • Loading branch information
dvilelaf committed Jan 31, 2024
1 parent 68343ba commit b9a2313
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 12 additions & 2 deletions backend/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ def build_deployment(self, service_id, key_names, env_vars=None):
service_dir = self.get_service_dir(service_id)
build_dir = self.get_build_dir(service_id)

# Remove build if it exists
if Path.exists(build_dir):
pass


# Load the service config
service_config = self.get_service_config(service_id)

Expand Down Expand Up @@ -144,11 +149,16 @@ def build_deployment(self, service_id, key_names, env_vars=None):
# Add data volume to docker-compose.yaml
add_volume_to_service(
Path(build_dir, "docker-compose.yaml"),
PublicId.from_str(service_id).name,
f"{PublicId.from_str(service_id).name}_abci_0",
"data",
self.get_volume_dir(service_id)
)

# Write env file
self.write_env_file(service_id, key_names, env_vars)

def write_env_file(self, service_id, key_names, env_vars):
pass

def start_service(self, service_id):
build_dir = self.get_build_dir(service_id)
Expand All @@ -165,5 +175,5 @@ def stop_service(self, service_id):

service_id = "valory/trader:0.1.0:bafybeifhq2udyttnuidkc7nmtjcfzivbbnfcayixzps7fa5x3cg353bvfe"
controller = Controller()
controller.build_deployment(service_id, ["true-dane"])
# controller.build_deployment(service_id, ["true-dane"])
controller.start_service(service_id)
4 changes: 1 addition & 3 deletions backend/scripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ def add_volume_to_service(compose_file, service_name, volume_name, volume_path):
if service_name not in compose_data["services"].keys():
return

relative_volume_path = volume_path.relative_to(compose_file.parent)

compose_data["services"][service_name]["volumes"].append(
f"./{str(relative_volume_path)}:/{volume_name}:Z"
f"./{str(volume_path)}:/{volume_name}:Z"
)

with open(compose_file, "w") as compose:
Expand Down

0 comments on commit b9a2313

Please sign in to comment.