Skip to content

Commit

Permalink
feat(ecs): added management command for collectstatic, refactor, mino…
Browse files Browse the repository at this point in the history
…r fixes
  • Loading branch information
Brian Caffey committed May 12, 2021
1 parent d1bc46c commit 6254f5f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: synth test deploy
.PHONY: synth test deploy diff

synth:
cdk synth --app='./lib/integ.default.js'
Expand All @@ -9,5 +9,13 @@ deploy:
destroy:
cdk destroy --app='./lib/integ.default.js'

diff:
cdk diff --app='./lib/integ.default.js'

build:
npm run build

build-deploy: build deploy

test:
npm run test
12 changes: 9 additions & 3 deletions src/django-cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class DjangoCdk extends cdk.Construct {
POSTGRES_SERVICE_HOST: database.rdsPostgresInstance.dbInstanceEndpointAddress,
POSTGRES_PASSWORD: this.secret.secretValue.toString(),
DEBUG: '0',
DJANGO_SETTINGS_MODULE: 'backend.settings.base',
DJANGO_SETTINGS_MODULE: 'backend.settings.production',
};

taskDefinition.addContainer('backendContainer', {
Expand Down Expand Up @@ -123,22 +123,28 @@ export class DjangoCdk extends cdk.Construct {
vpc: this.vpc,
});

// const collectstaticTask =
new managementCommandTask(scope, 'migrate', {
image: this.image,
command: ['python3', 'manage.py', 'migrate', '--no-input'],
appSecurityGroup,
environment,
});

new managementCommandTask(scope, 'collectstatic', {
image: this.image,
command: ['python3', 'manage.py', 'collectstatic', '--no-input'],
appSecurityGroup,
environment,
});

/**
* ECS load-balanced fargate service
*/
const albfs = new patterns.ApplicationLoadBalancedFargateService(scope, 'AlbFargateService', {
cluster: this.cluster,
taskDefinition,
securityGroups: [appSecurityGroup],
desiredCount: 2,
desiredCount: 1,
assignPublicIp: true,
});

Expand Down
9 changes: 1 addition & 8 deletions src/integ.default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,7 @@ const stack = new cdk.Stack(app, 'MyStack', { env });
const construct = new DjangoCdk(stack, 'Cdk-Sample-Lib', {
imageDirectory: './test/django-step-by-step/backend',
webCommand: [
'gunicorn',
'-t',
'300',
'-w',
'4',
'-b',
'0.0.0.0:8000',
'backend.wsgi',
'./scripts/start_prod.sh',
],
});

Expand Down
2 changes: 1 addition & 1 deletion test/django-step-by-step

0 comments on commit 6254f5f

Please sign in to comment.