Skip to content
This repository was archived by the owner on Mar 27, 2023. It is now read-only.

Commit 8189bfe

Browse files
committed
Merge branch '27-refactor-asset-image' into 'develop'
define image in cdk_app_root and reuse in services Closes #27 See merge request verbose-equals-true/django-postgres-vue-gitlab-ecs!71
2 parents 9eddff8 + a135b3e commit 8189bfe

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

awscdk/awscdk/backend.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def __init__(
1414
self,
1515
scope: core.Construct,
1616
id: str,
17+
image: ecs.AssetImage,
1718
load_balancer,
1819
cluster: ecs.ICluster,
1920
environment_variables: core.Construct,
@@ -28,11 +29,7 @@ def __init__(
2829

2930
self.backend_task.add_container(
3031
"DjangoBackend",
31-
image=ecs.AssetImage(
32-
"../backend",
33-
file="scripts/prod/Dockerfile",
34-
target="production",
35-
),
32+
image=image,
3633
logging=ecs.LogDrivers.aws_logs(stream_prefix="Backend"),
3734
environment=environment_variables.regular_variables,
3835
secrets=environment_variables.secret_variables,

awscdk/awscdk/backend_tasks.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def __init__(
1111
self,
1212
scope: core.Construct,
1313
id: str,
14+
image: ecs.AssetImage,
1415
cluster: ecs.ICluster,
1516
environment_variables: core.Construct,
1617
full_app_name: str,
@@ -20,10 +21,6 @@ def __init__(
2021
scope, id, **kwargs,
2122
)
2223

23-
image = ecs.AssetImage(
24-
"../backend", file="scripts/prod/Dockerfile", target="production",
25-
)
26-
2724
self.migrate_task = ecs.FargateTaskDefinition(
2825
self, "MigrateTask", family=f"{full_app_name}-migrate"
2926
)

awscdk/awscdk/cdk_app_root.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from aws_cdk import core
1+
from aws_cdk import core, aws_ecs as ecs
22

33
from cert import SiteCertificate
44
from hosted_zone import HostedZone
@@ -78,6 +78,12 @@ def __init__(
7878
# self, "ElastiCacheRedis", vpc=self.vpc.vpc
7979
# )
8080

81+
# image used for all django containers
82+
# gunicorn, daphne, celery workers, celery beat
83+
self.image = ecs.AssetImage(
84+
"../backend", file="scripts/prod/Dockerfile", target="production",
85+
)
86+
8187
self.variables = Variables(
8288
self,
8389
"Variables",
@@ -91,6 +97,7 @@ def __init__(
9197
self.backend = Backend(
9298
self,
9399
"Backend",
100+
image=self.image,
94101
load_balancer=self.alb,
95102
cluster=self.ecs.cluster,
96103
environment_variables=self.variables,
@@ -101,6 +108,7 @@ def __init__(
101108
self.backend_tasks = BackendTasks(
102109
self,
103110
"BackendTasks",
111+
image=self.image,
104112
cluster=self.ecs.cluster,
105113
environment_variables=self.variables,
106114
full_app_name=full_app_name,

0 commit comments

Comments
 (0)