entrypoint, cmd, mount dir, work dir params

pull/218/head
Frostebite 2021-02-12 21:25:44 +00:00 committed by GitHub
parent 9c34e1abac
commit 39ad2c81ad
3 changed files with 46 additions and 10 deletions

File diff suppressed because one or more lines are too long

View File

@ -30,18 +30,24 @@ Parameters:
Type: Number Type: Number
Default: 512 Default: 512
Description: How much memory in megabytes to give the container Description: How much memory in megabytes to give the container
Prefix: Command:
Type: String Type: String
Default: test Default: 'ls'
EntryPoint:
Type: String
Default: '/bin/sh,-c'
WorkingDirectory:
Type: String
Default: '/efsdata/'
Role: Role:
Type: String Type: String
Default: '' Default: ''
Description: >- Description: >-
(Optional) An IAM role to give the service's containers if the code within (Optional) An IAM role to give the service's containers if the code within
needs to access other AWS resources like S3 buckets, DynamoDB tables, etc needs to access other AWS resources like S3 buckets, DynamoDB tables, etc
EFSMountPath: EFSMountDirectory:
Type: String Type: String
Default: /usr/share/nginx/html Default: /efsdata
Mappings: Mappings:
SubnetConfig: SubnetConfig:
VPC: VPC:
@ -115,12 +121,21 @@ Resources:
Cpu: !Ref ContainerCpu Cpu: !Ref ContainerCpu
Memory: !Ref ContainerMemory Memory: !Ref ContainerMemory
Image: !Ref ImageUrl Image: !Ref ImageUrl
EntryPoint:
Fn::Split:
- ","
- !Ref EntryPoint
Command:
Fn::Split:
- ","
- !Ref Commands
WorkDir: !Ref WorkingDirectory
Environment: Environment:
- Name: ALLOW_EMPTY_PASSWORD - Name: ALLOW_EMPTY_PASSWORD
Value: 'yes' Value: 'yes'
MountPoints: MountPoints:
- SourceVolume: efs-data - SourceVolume: efs-data
ContainerPath: !Ref EFSMountPath ContainerPath: !Ref EFSMountDirectory
ReadOnly: false ReadOnly: false
LogConfiguration: LogConfiguration:
LogDriver: awslogs LogDriver: awslogs

View File

@ -12,7 +12,10 @@ class AWS {
await this.run( await this.run(
buildParameters.awsStackName, buildParameters.awsStackName,
'alpine/git', 'alpine/git',
['git'],
['clone', `https://github.com/${process.env.GITHUB_REPOSITORY}.git`, `repo`], ['clone', `https://github.com/${process.env.GITHUB_REPOSITORY}.git`, `repo`],
'/efsdata',
'/efsdata/',
[ [
{ {
name: 'GITHUB_SHA', name: 'GITHUB_SHA',
@ -23,12 +26,15 @@ class AWS {
await this.run( await this.run(
buildParameters.awsStackName, buildParameters.awsStackName,
baseImage.toString(), baseImage.toString(),
['bin/bash', '-c', 'echo "test"'], ['bin/bash', '-c'],
['echo', '"test"'],
'/efsdata',
'/efsdata/',
[], [],
); );
} }
static async run(stackName, image, commands, environment) { static async run(stackName, image, entrypoint, commands, mountdir, workingdir, environment) {
const ECS = new SDK.ECS(); const ECS = new SDK.ECS();
const CF = new SDK.CloudFormation(); const CF = new SDK.CloudFormation();
@ -49,6 +55,22 @@ class AWS {
ParameterKey: 'ServiceName', ParameterKey: 'ServiceName',
ParameterValue: taskDefStackName, ParameterValue: taskDefStackName,
}, },
{
ParameterKey: 'Command',
ParameterValue: commands.join(','),
},
{
ParameterKey: 'EntryPoint',
ParameterValue: entrypoint.join(','),
},
{
ParameterKey: 'WorkingDirectory',
ParameterValue: workingdir,
},
{
ParameterKey: 'EFSMountDirectory',
ParameterValue: mountdir,
},
], ],
}).promise(); }).promise();
await CF.waitFor('stackCreateComplete', { StackName: taskDefStackName }).promise(); await CF.waitFor('stackCreateComplete', { StackName: taskDefStackName }).promise();
@ -68,16 +90,15 @@ class AWS {
(x) => x.LogicalResourceId === 'TaskDefinition', (x) => x.LogicalResourceId === 'TaskDefinition',
).PhysicalResourceId, ).PhysicalResourceId,
platformVersion: '1.4.0', platformVersion: '1.4.0',
launchType: 'FARGATE',
overrides: { overrides: {
containerOverrides: [ containerOverrides: [
{ {
name: taskDefStackName, name: taskDefStackName,
environment, environment,
command: commands,
}, },
], ],
}, },
launchType: 'FARGATE',
networkConfiguration: { networkConfiguration: {
awsvpcConfiguration: { awsvpcConfiguration: {
subnets: [ subnets: [