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

Commit 855c664

Browse files
committed
Merge branch 'develop'
2 parents 8b53c63 + 520216a commit 855c664

File tree

20 files changed

+150
-110
lines changed

20 files changed

+150
-110
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: 13 additions & 4 deletions
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
@@ -74,9 +74,15 @@ def __init__(
7474
self, "RdsDBCluster", vpc=self.vpc.vpc, full_app_name=full_app_name
7575
)
7676

77-
# self.elasticache = ElastiCache(
78-
# self, "ElastiCacheRedis", vpc=self.vpc.vpc
79-
# )
77+
self.elasticache = ElastiCache(
78+
self, "ElastiCacheRedis", vpc=self.vpc.vpc
79+
)
80+
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+
)
8086

8187
self.variables = Variables(
8288
self,
@@ -86,11 +92,13 @@ def __init__(
8692
postgres_host=self.rds.rds_cluster.get_att(
8793
"Endpoint.Address"
8894
).to_string(),
95+
redis_host=self.elasticache.elasticache.attr_redis_endpoint_address, # noqa
8996
)
9097

9198
self.backend = Backend(
9299
self,
93100
"Backend",
101+
image=self.image,
94102
load_balancer=self.alb,
95103
cluster=self.ecs.cluster,
96104
environment_variables=self.variables,
@@ -101,6 +109,7 @@ def __init__(
101109
self.backend_tasks = BackendTasks(
102110
self,
103111
"BackendTasks",
112+
image=self.image,
104113
cluster=self.ecs.cluster,
105114
environment_variables=self.variables,
106115
full_app_name=full_app_name,

awscdk/awscdk/elasticache.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ def __init__(
2323
ip_protocol="tcp",
2424
to_port=6379,
2525
from_port=6379,
26-
# TODO: replace this with ECS security group
27-
source_security_group_id="security-group-id",
26+
source_security_group_id=vpc.vpc_default_security_group,
2827
)
2928
],
3029
)
@@ -47,5 +46,5 @@ def __init__(
4746
vpc_security_group_ids=[
4847
self.elasticache_security_group.get_att("GroupId").to_string()
4948
],
50-
cache_subnet_group_name=self.elasticache_subnet_group.cache_subnet_group_name,
49+
cache_subnet_group_name=self.elasticache_subnet_group.cache_subnet_group_name, # noqa
5150
)

awscdk/awscdk/env_vars.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def __init__(
1010
id: str,
1111
bucket_name: str,
1212
postgres_host: str,
13+
redis_host: str,
1314
db_secret: secrets.ISecret,
1415
**kwargs,
1516
) -> None:
@@ -36,6 +37,7 @@ def __init__(
3637
"SECRET_KEY": os.environ.get(
3738
"SECRET_KEY", "mysecretkey123"
3839
), # self.django_secret_key.to_string(),
40+
"REDIS_SERVICE_HOST": redis_host,
3941
}
4042

4143
self.secret_variables = {

awscdk/stack.yml

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,6 @@ Resources:
665665
- - "{{resolve:secretsmanager:"
666666
- Ref: RdsDBClusterDBSecret28397CCA
667667
- :SecretString:password::}}
668-
Port: 5432
669668
Tags:
670669
- Key: StackName
671670
Value: dev-mysite-com
@@ -675,6 +674,49 @@ Resources:
675674
- GroupId
676675
Metadata:
677676
aws:cdk:path: dev-mysite-com-stack/RdsDBCluster/DBCluster
677+
ElastiCacheRedisElastiCacheSecurityGroupA36895A6:
678+
Type: AWS::EC2::SecurityGroup
679+
Properties:
680+
GroupDescription: ElastiCacheSecurityGroup
681+
SecurityGroupIngress:
682+
- FromPort: 6379
683+
IpProtocol: tcp
684+
SourceSecurityGroupId:
685+
Fn::GetAtt:
686+
- VpcC3027511
687+
- DefaultSecurityGroup
688+
ToPort: 6379
689+
Tags:
690+
- Key: StackName
691+
Value: dev-mysite-com
692+
VpcId:
693+
Ref: VpcC3027511
694+
Metadata:
695+
aws:cdk:path: dev-mysite-com-stack/ElastiCacheRedis/ElastiCacheSecurityGroup
696+
ElastiCacheRedisCfnSubnetGroup403949FE:
697+
Type: AWS::ElastiCache::SubnetGroup
698+
Properties:
699+
Description: The subnet group for ElastiCache
700+
SubnetIds:
701+
- Ref: VpcIsolatedSubnet1SubnetDC3C6AF8
702+
- Ref: VpcIsolatedSubnet2SubnetB479B99C
703+
Metadata:
704+
aws:cdk:path: dev-mysite-com-stack/ElastiCacheRedis/CfnSubnetGroup
705+
ElastiCacheRedisElastiCacheClusterRedis25390D9F:
706+
Type: AWS::ElastiCache::CacheCluster
707+
Properties:
708+
CacheNodeType: cache.t2.micro
709+
Engine: redis
710+
NumCacheNodes: 1
711+
Tags:
712+
- Key: StackName
713+
Value: dev-mysite-com
714+
VpcSecurityGroupIds:
715+
- Fn::GetAtt:
716+
- ElastiCacheRedisElastiCacheSecurityGroupA36895A6
717+
- GroupId
718+
Metadata:
719+
aws:cdk:path: dev-mysite-com-stack/ElastiCacheRedis/ElastiCacheClusterRedis
678720
VariablesDjangoSecretKeyE4FA41EE:
679721
Type: AWS::SecretsManager::Secret
680722
Properties:
@@ -766,6 +808,11 @@ Resources:
766808
- :SecretString:password::}}
767809
- Name: SECRET_KEY
768810
Value: mysecretkey123
811+
- Name: REDIS_SERVICE_HOST
812+
Value:
813+
Fn::GetAtt:
814+
- ElastiCacheRedisElastiCacheClusterRedis25390D9F
815+
- RedisEndpoint.Address
769816
Essential: true
770817
Image:
771818
Fn::Join:
@@ -967,6 +1014,11 @@ Resources:
9671014
- :SecretString:password::}}
9681015
- Name: SECRET_KEY
9691016
Value: mysecretkey123
1017+
- Name: REDIS_SERVICE_HOST
1018+
Value:
1019+
Fn::GetAtt:
1020+
- ElastiCacheRedisElastiCacheClusterRedis25390D9F
1021+
- RedisEndpoint.Address
9701022
Essential: true
9711023
Image:
9721024
Fn::Join:
@@ -1149,6 +1201,11 @@ Resources:
11491201
- :SecretString:password::}}
11501202
- Name: SECRET_KEY
11511203
Value: mysecretkey123
1204+
- Name: REDIS_SERVICE_HOST
1205+
Value:
1206+
Fn::GetAtt:
1207+
- ElastiCacheRedisElastiCacheClusterRedis25390D9F
1208+
- RedisEndpoint.Address
11521209
Essential: true
11531210
Image:
11541211
Fn::Join:
@@ -1330,6 +1387,11 @@ Resources:
13301387
- :SecretString:password::}}
13311388
- Name: SECRET_KEY
13321389
Value: mysecretkey123
1390+
- Name: REDIS_SERVICE_HOST
1391+
Value:
1392+
Fn::GetAtt:
1393+
- ElastiCacheRedisElastiCacheClusterRedis25390D9F
1394+
- RedisEndpoint.Address
13331395
Essential: true
13341396
Image:
13351397
Fn::Join:

backend/scripts/ci/Dockerfile

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ ADD backend/ /code/
1515

1616
# build stage that generates quasar assets
1717
FROM node:10-alpine as build-stage
18-
ENV HTTP_PROTOCOL http
19-
ENV WS_PROTOCOL ws
20-
ENV DOMAIN_NAME localhost:9000
18+
ENV FULL_DOMAIN_NAME localhost:9000
2119
WORKDIR /app/
2220
COPY quasar/package.json /app/
2321
RUN npm cache verify
@@ -43,9 +41,9 @@ RUN npm -v
4341

4442
# cypress dependencies
4543
RUN apt-get -qq install -y xvfb \
46-
libgtk-3-dev \
47-
libnotify-dev \
48-
libgconf-2-4 \
49-
libnss3 \
50-
libxss1 \
51-
libasound2
44+
libgtk-3-dev \
45+
libnotify-dev \
46+
libgconf-2-4 \
47+
libnss3 \
48+
libxss1 \
49+
libasound2

compose/minikube.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
version: '3.7'
1+
version: "3.7"
22

33
services:
4-
54
frontend:
65
image: frontend:2
76
build:
87
context: ../
98
dockerfile: nginx/minikube/Dockerfile
109
args:
11-
- DOMAIN_NAME=minikube.local
10+
- FULL_DOMAIN_NAME=minikube.local
1211
- GOOGLE_OAUTH2_KEY=google123
1312
- GITHUB_KEY=github123
14-
- WS_PROTOCOL=ws
15-
- HTTP_PROTOCOL=http
1613

1714
backend:
1815
image: backend:1
1916
build:
2017
context: ../backend/
2118
dockerfile: scripts/dev/Dockerfile
22-

docker-compose.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ services:
7373
- GITHUB_KEY=${GITHUB_KEY}
7474
- GOOGLE_OAUTH2_KEY=${GOOGLE_OAUTH2_KEY}
7575
- FACEBOOK_KEY=${FACEBOOK_KEY}
76-
- HTTP_PROTOCOL=http
77-
- WS_PROTOCOL=ws
78-
- DOMAIN_NAME=${DOMAIN_NAME}
76+
- FULL_DOMAIN_NAME=${DOMAIN_NAME}
7977
restart: "no"
8078

8179
backend: &backend
@@ -182,7 +180,7 @@ services:
182180
PGADMIN_DEFAULT_EMAIL: pgadmin4@pgadmin.org
183181
PGADMIN_DEFAULT_PASSWORD: admin
184182
volumes:
185-
- pgadmin:/root/.pgadmin
183+
- pgadmin:/root/.pgadmin
186184
ports:
187185
- "5050:80"
188186
depends_on:

documentation/docs/topics/minikube/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -775,11 +775,9 @@ services:
775775
context: ../
776776
dockerfile: nginx/minikube/Dockerfile
777777
args:
778-
- DOMAIN_NAME=minikube.local
778+
- FULL_DOMAIN_NAME=minikube.local
779779
- GOOGLE_OAUTH2_KEY=google123
780780
- GITHUB_KEY=github123
781-
- WS_PROTOCOL=ws
782-
- HTTP_PROTOCOL=http
783781
```
784782

785783
Make sure that your current shell has the correct environment variables set for the `DOCKER_HOST` by running:

0 commit comments

Comments
 (0)