diff --git a/autonomy/deploy/base.py b/autonomy/deploy/base.py
index 44adc93c85..1ea737f508 100644
--- a/autonomy/deploy/base.py
+++ b/autonomy/deploy/base.py
@@ -169,7 +169,7 @@ def __init__( # pylint: disable=too-many-arguments
if apply_environment_variables:
warn( # pragma: no cover
"`apply_environment_variables` argument is deprecated and will be removed in v1.0.0, "
- "usage of environment varibales is default now.",
+ "usage of environment variables is default now.",
DeprecationWarning,
stacklevel=2,
)
@@ -731,13 +731,10 @@ def generate_common_vars(self, agent_n: int) -> Dict:
ENV_VAR_ID: agent_n,
ENV_VAR_AEA_AGENT: self.service.agent,
ENV_VAR_LOG_LEVEL: self.log_level,
- }
- if self.deplopyment_type == DOCKER_COMPOSE_DEPLOYMENT:
- agent_vars[ENV_VAR_AEA_PASSWORD] = "$OPEN_AUTONOMY_PRIVATE_KEY_PASSWORD"
- else:
- agent_vars[ENV_VAR_AEA_PASSWORD] = os.environ.get(
+ ENV_VAR_AEA_PASSWORD: os.environ.get(
"OPEN_AUTONOMY_PRIVATE_KEY_PASSWORD", ""
- )
+ ),
+ }
return agent_vars
def generate_agent(
diff --git a/autonomy/deploy/generators/docker_compose/base.py b/autonomy/deploy/generators/docker_compose/base.py
index 28e4bbcf0e..d1fe7b2a21 100644
--- a/autonomy/deploy/generators/docker_compose/base.py
+++ b/autonomy/deploy/generators/docker_compose/base.py
@@ -18,6 +18,7 @@
# ------------------------------------------------------------------------------
"""Docker-compose Deployment Generator."""
+
import ipaddress
import os
from pathlib import Path
@@ -131,8 +132,19 @@ def build_tendermint_node_config( # pylint: disable=too-many-arguments
return config
+def to_env_file(agent_vars: Dict, node_id: int, build_dir: Path) -> None:
+ """Create a env file under the `agent_build` folder."""
+ agent_vars["PYTHONHASHSEED"] = 0
+ agent_vars["LOG_FILE"] = f"/logs/aea_{node_id}.txt"
+ env_file_path = build_dir / f"agent_{node_id}.env"
+ with open(env_file_path, "w", encoding=DEFAULT_ENCODING) as env_file:
+ for key, value in agent_vars.items():
+ env_file.write(f"{key}={value}\n")
+
+
def build_agent_config( # pylint: disable=too-many-arguments,too-many-locals
node_id: int,
+ build_dir: Path,
container_name: str,
agent_vars: Dict,
runtime_image: str,
@@ -147,13 +159,13 @@ def build_agent_config( # pylint: disable=too-many-arguments,too-many-locals
) -> str:
"""Build agent config."""
resources = resources if resources is not None else DEFAULT_RESOURCE_VALUES
- agent_vars_string = "\n".join([f" - {k}={v}" for k, v in agent_vars.items()])
+ to_env_file(agent_vars, node_id, build_dir)
config = ABCI_NODE_TEMPLATE.format(
node_id=node_id,
container_name=container_name,
- agent_vars=agent_vars_string,
network_address=network_address,
runtime_image=runtime_image,
+ env_file=f"agent_{node_id}.env",
network_name=network_name,
agent_memory_request=resources["agent"]["requested"]["memory"],
agent_cpu_limit=resources["agent"]["limit"]["cpu"],
@@ -167,13 +179,9 @@ def build_agent_config( # pylint: disable=too-many-arguments,too-many-locals
config += f" - {open_aea_dir}:/open-aea\n"
if extra_volumes is not None:
- if all(isinstance(i, int) for i in extra_volumes):
- extra_volumes = extra_volumes.get(node_id, {}) # type: ignore
- for host_dir, container_dir in extra_volumes.items(): # type: ignore
- vol_dir = Path(host_dir).resolve()
- if not vol_dir.exists():
- vol_dir.mkdir(parents=True)
- config += f" - {vol_dir}:{container_dir}:Z\n"
+ for host_dir, container_dir in extra_volumes.items():
+ config += f" - {host_dir}:{container_dir}:Z\n"
+ Path(host_dir).resolve().mkdir(exist_ok=True, parents=True)
if agent_ports is not None:
port_mappings = map(
@@ -354,6 +362,7 @@ def generate(
container_name=self.service_builder.get_abci_container_name(
index=i
),
+ build_dir=self.build_dir,
runtime_image=runtime_image,
agent_vars=agent_vars[i],
dev_mode=self.dev_mode,
diff --git a/autonomy/deploy/generators/docker_compose/templates.py b/autonomy/deploy/generators/docker_compose/templates.py
index 7d52be35c9..b6d01efe4b 100644
--- a/autonomy/deploy/generators/docker_compose/templates.py
+++ b/autonomy/deploy/generators/docker_compose/templates.py
@@ -104,10 +104,7 @@
cpus: {agent_cpu_limit}
container_name: {container_name}
image: {runtime_image}
- environment:
- - PYTHONHASHSEED=0
- - LOG_FILE=/logs/aea_{node_id}.txt
-{agent_vars}
+ env_file: {env_file}
networks:
{network_name}:
ipv4_address: {network_address}
diff --git a/deployments/Dockerfiles/autonomy/scripts/install.sh b/deployments/Dockerfiles/autonomy/scripts/install.sh
index 311e8a0f73..696129a475 100644
--- a/deployments/Dockerfiles/autonomy/scripts/install.sh
+++ b/deployments/Dockerfiles/autonomy/scripts/install.sh
@@ -18,7 +18,7 @@ echo "Successfully built the host dependencies."
echo "Installing the necessary python dependencies!"
aea install --timeout 600 $EXTRA_DEPENDENCIES || exit 1
-echo "Successfully Installed the python dependecies."
+echo "Successfully Installed the python dependencies."
echo "Done."
cd ..
diff --git a/docs/api/deploy/generators/docker_compose/base.md b/docs/api/deploy/generators/docker_compose/base.md
index 71cb562363..e53288602f 100644
--- a/docs/api/deploy/generators/docker_compose/base.md
+++ b/docs/api/deploy/generators/docker_compose/base.md
@@ -32,12 +32,23 @@ def build_tendermint_node_config(
Build tendermint node config for docker compose.
+
+
+#### to`_`env`_`file
+
+```python
+def to_env_file(agent_vars: Dict, node_id: int, build_dir: Path) -> None
+```
+
+Create a env file under the `agent_build` folder.
+
#### build`_`agent`_`config
```python
def build_agent_config(node_id: int,
+ build_dir: Path,
container_name: str,
agent_vars: Dict,
runtime_image: str,