Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
61 changes: 49 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ amazon-linux-sources.tgz:

amazon-linux-rpm-integrated: .amazon-linux-rpm-integrated-done

.generic-rpm-integrated-done:
.generic-rpm-integrated-done: get-cni-sources
./scripts/update-version.sh
cp packaging/generic-rpm-integrated/amazon-ecs-init.spec amazon-ecs-init.spec
cp packaging/generic-rpm-integrated/ecs.service ecs.service
Expand All @@ -388,7 +388,40 @@ amazon-linux-rpm-integrated: .amazon-linux-rpm-integrated-done

generic-rpm-integrated: .generic-rpm-integrated-done

.generic-rpm-done:
VERSION = $(shell cat ecs-init/ECSVERSION)

.generic-deb-integrated-done: get-cni-sources
mkdir -p BUILDROOT
./scripts/update-version.sh
tar -czf ./amazon-ecs-init_${VERSION}.orig.tar.gz ecs-init scripts README.md
cp -r packaging/generic-deb-integrated/debian ecs-init scripts misc agent agent-container amazon-ecs-cni-plugins amazon-vpc-cni-plugins README.md VERSION BUILDROOT
cd BUILDROOT && debuild -uc -us --lintian-opts --suppress-tags bad-distribution-in-changes-file,file-in-unusual-dir
touch .generic-deb-integrated-done

generic-deb-integrated: .generic-deb-integrated-done

ARCH:=$(shell uname -m)
ifeq (${ARCH},x86_64)
AGENT_FILENAME=ecs-agent-v${VERSION}.tar
else ifeq (${ARCH},aarch64)
AGENT_FILENAME=ecs-agent-arm64-v${VERSION}.tar
# osx M1 instances
else ifeq (${ARCH},arm64)
AGENT_FILENAME=ecs-agent-arm64-v${VERSION}.tar
endif

BUILDROOT/ecs-agent.tar:
mkdir -p BUILDROOT
curl -o BUILDROOT/ecs-agent.tar https://s3.amazonaws.com/amazon-ecs-agent/${AGENT_FILENAME}

${AGENT_FILENAME}: BUILDROOT/ecs-agent.tar
cp BUILDROOT/ecs-agent.tar ${AGENT_FILENAME}

rpm-in-docker: ${AGENT_FILENAME}
docker build -t "amazon/amazon-ecs-init:build" -f "scripts/dockerfiles/build.dockerfile" .
docker run -u "$(shell id -u)" --tmpfs /.cache -v "$(shell pwd):/workspace/amazon-ecs-init" "amazon/amazon-ecs-init:build"

.generic-rpm-done: ${AGENT_FILENAME}
./scripts/update-version.sh
cp packaging/generic-rpm/amazon-ecs-init.spec amazon-ecs-init.spec
cp packaging/generic-rpm/ecs.service ecs.service
Expand All @@ -409,26 +442,17 @@ generic-rpm: .generic-rpm-done
cd BUILDROOT && debuild -uc -us --lintian-opts --suppress-tags bad-distribution-in-changes-file,file-in-unusual-dir
touch .deb-done

.PHONY: deb
deb: .deb-done

clean:
# ensure docker is running and we can talk to it, abort if not:
docker ps > /dev/null
-docker rmi $(BUILDER_IMAGE) "amazon/amazon-ecs-agent-cleanbuild:make"
-docker rmi $(BUILDER_IMAGE) "amazon/amazon-ecs-agent-cleanbuild-windows:make"
rm -f misc/certs/host-certs.crt &> /dev/null
rm -rf misc/pause-container/image/
rm -rf misc/pause-container/rootfs/
rm -rf misc/plugins/
rm -rf out/
rm -rf rootfs/
-$(MAKE) -C $(ECS_CNI_REPOSITORY_SRC_DIR) clean
-$(MAKE) -C misc/netkitten $(MFLAGS) clean
-$(MAKE) -C misc/volumes-test $(MFLAGS) clean
-$(MAKE) -C misc/exec-command-agent-test $(MFLAGS) clean
-$(MAKE) -C misc/gremlin $(MFLAGS) clean
-$(MAKE) -C misc/image-cleanup-test-images $(MFLAGS) clean
-$(MAKE) -C misc/container-health $(MFLAGS) clean
-rm -f .get-deps-stamp
-rm -f .builder-image-stamp
-rm -f .out-stamp
Expand Down Expand Up @@ -460,3 +484,16 @@ clean:
-rm -f .amazon-linux-rpm-integrated-done
-rm -f .generic-rpm-integrated-done
-rm -f amazon-ecs-volume-plugin

clean-all: clean
# for our dockerfree builds, we likely don't have docker
# ensure docker is running and we can talk to it, abort if not:
docker ps > /dev/null
-docker rmi $(BUILDER_IMAGE) "amazon/amazon-ecs-agent-cleanbuild:make"
-docker rmi $(BUILDER_IMAGE) "amazon/amazon-ecs-agent-cleanbuild-windows:make"
-$(MAKE) -C misc/netkitten $(MFLAGS) clean
-$(MAKE) -C misc/volumes-test $(MFLAGS) clean
-$(MAKE) -C misc/exec-command-agent-test $(MFLAGS) clean
-$(MAKE) -C misc/gremlin $(MFLAGS) clean
-$(MAKE) -C misc/image-cleanup-test-images $(MFLAGS) clean
-$(MAKE) -C misc/container-health $(MFLAGS) clean
109 changes: 108 additions & 1 deletion build-infrastructure/codebuild-devbuild-stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,60 @@ Parameters:
Description: Base name of CodeBuild projects - will start different CodeBuild projects with different suffixes (-amd, -arm) for different artifacts

Resources:
UbuntuAmdProject:
Type: 'AWS::CodeBuild::Project'
Properties:
Artifacts:
Location: !Ref BuildBucketName
NamespaceType: NONE
OverrideArtifactName: true
Packaging: NONE
Path: development
Type: S3
BadgeEnabled: false
ConcurrentBuildLimit: 10
Description: A CodeBuild project to build artifacts (AMD/x86_64). Builds are triggered by PR creation and updates, and artifacts are saved in S3
Environment:
ComputeType: BUILD_GENERAL1_SMALL
Image: 'aws/codebuild/standard:5.0'
ImagePullCredentialsType: CODEBUILD
PrivilegedMode: false
Type: LINUX_CONTAINER
Name: !Sub '${BuildProjectName}-ubuntu-amd'
QueuedTimeoutInMinutes: 60
ServiceRole: !Ref ServiceRoleUbuntuAmd
Source:
BuildSpec: buildspecs/pr-build-ubuntu.yml
Location: !Ref GithubFullRepoName
Type: GITHUB
TimeoutInMinutes: 60
Triggers:
BuildType: BUILD
# Config list of developers allowlisted to create builds when creating PRs to GithubBranchName
# This allow list can be modified using aws-cli or aws-sdk
# CodeBuild also supports pattern matches using regex, but this is not useful for listing different Github IDs
# so they have to be listed separately
FilterGroups:
- - Type: EVENT
Pattern: 'PULL_REQUEST_CREATED,PULL_REQUEST_UPDATED,PULL_REQUEST_REOPENED'
- Type: BASE_REF
Pattern: !Sub '^${GithubBranchName}$'
- Type: ACTOR_ACCOUNT_ID
Pattern: '5080306' # prateekchaudhry
- - Type: EVENT
Pattern: 'PULL_REQUEST_CREATED,PULL_REQUEST_UPDATED,PULL_REQUEST_REOPENED'
- Type: BASE_REF
Pattern: !Sub '^${GithubBranchName}$'
- Type: ACTOR_ACCOUNT_ID
Pattern: '4751028' # fierlion
- - Type: EVENT
Pattern: 'PULL_REQUEST_CREATED,PULL_REQUEST_UPDATED,PULL_REQUEST_REOPENED'
- Type: BASE_REF
Pattern: !Sub '^${GithubBranchName}$'
- Type: ACTOR_ACCOUNT_ID
Pattern: '3102848' # YashdalfTheGray
Webhook: true
Visibility: PRIVATE
ArmProject:
Type: 'AWS::CodeBuild::Project'
Properties:
Expand Down Expand Up @@ -180,6 +234,59 @@ Resources:
- 's3:GetBucketLocation'
PolicyName: !Sub '${AWS::StackName}-ServicePolicyAmd'
RoleName: !Sub '${AWS::StackName}-ServiceRoleAmd'
ServiceRoleUbuntuAmd:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service: codebuild.amazonaws.com
Action: 'sts:AssumeRole'
Description: Service role, allow access to CW and S3
Path: /
Policies:
- PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Resource:
- !Join
- ':'
- - 'arn:aws:logs'
- !Ref 'AWS::Region'
- !Ref 'AWS::AccountId'
- !Sub 'log-group:/aws/codebuild/${BuildProjectName}-ubuntu-amd'
- !Join
- ':'
- - 'arn:aws:logs'
- !Ref 'AWS::Region'
- !Ref 'AWS::AccountId'
- !Sub 'log-group:/aws/codebuild/${BuildProjectName}-ubuntu-amd:*'
Action:
- 'logs:CreateLogGroup'
- 'logs:CreateLogStream'
- 'logs:PutLogEvents'
- Effect: Allow
Resource:
- 'arn:aws:s3:::codepipeline-us-west-2-*'
Action:
- 's3:PutObject'
- 's3:GetObject'
- 's3:GetObjectVersion'
- 's3:GetBucketAcl'
- 's3:GetBucketLocation'
- Effect: Allow
Resource:
- !Sub '${BuildBucketArn}/*'
Action:
- 's3:GetObject'
- 's3:PutObject'
- 's3:GetBucketAcl'
- 's3:GetBucketLocation'
PolicyName: !Sub '${AWS::StackName}-ServicePolicyUbuntuAmd'
RoleName: !Sub '${AWS::StackName}-ServiceRoleUbuntuAmd'
ServiceRoleArm:
Type: 'AWS::IAM::Role'
Properties:
Expand Down Expand Up @@ -232,4 +339,4 @@ Resources:
- 's3:GetBucketAcl'
- 's3:GetBucketLocation'
PolicyName: !Sub '${AWS::StackName}-ServicePolicyArm'
RoleName: !Sub '${AWS::StackName}-ServiceRoleArm'
RoleName: !Sub '${AWS::StackName}-ServiceRoleArm'
Loading