Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
container_name="my-app",
container_location=f"ghcr.io/sage-bionetworks/my-app:{app_version}",
container_port=80,
container_memory=200,
container_cpu=256,
container_memory=512,
container_env_vars={
"APP_VERSION": f"{app_version}",
},
Expand Down
3 changes: 3 additions & 0 deletions src/service_props.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class ServiceProps:
supports "path://" for building container from local (i.e. path://docker/MyContainer)
supports docker registry references (i.e. ghcr.io/sage-bionetworks/app:latest)
container_port: the container application port
container_cpu: the container application CPU in millicores (i.e. 1024 = 1 vCPU)
container_memory: the container application memory
container_env_vars: a json dictionary of environment variables to pass into the container
i.e. {"EnvA": "EnvValueA", "EnvB": "EnvValueB"}
Expand All @@ -69,6 +70,7 @@ def __init__(
container_name: str,
container_location: str,
container_port: int,
container_cpu: int = 256,
container_memory: int = 512,
container_env_vars: dict = None,
container_secrets: List[ServiceSecret] = None,
Expand All @@ -80,6 +82,7 @@ def __init__(
) -> None:
self.container_name = container_name
self.container_port = container_port
self.container_cpu = container_cpu
self.container_memory = container_memory
if CONTAINER_LOCATION_PATH_ID in container_location:
container_location = container_location.removeprefix(
Expand Down
4 changes: 2 additions & 2 deletions src/service_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def __init__(
self.task_definition = ecs.FargateTaskDefinition(
self,
"TaskDef",
cpu=1024,
memory_limit_mib=4096,
cpu=props.container_cpu,
memory_limit_mib=props.container_memory,
task_role=task_role,
execution_role=execution_role,
)
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/test_service_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def test_service_stack_created():
container_name="app",
container_location="ghcr.io/sage-bionetworks/app:1.0",
container_port=8010,
container_memory=200,
container_cpu=256,
container_memory=512,
container_secrets=[
ServiceSecret(
secret_name="/app/secret",
Expand All @@ -45,7 +46,7 @@ def test_service_stack_created():
"ContainerDefinitions": [
{
"Image": "ghcr.io/sage-bionetworks/app:1.0",
"Memory": 200,
"Memory": 512,
"MountPoints": [{"ContainerPath": "/work"}],
"Secrets": [{"Name": "APP_SECRET"}],
"Command": ["test"],
Expand Down