You've already forked microservices
mirror of
https://github.com/ebosas/microservices.git
synced 2025-08-24 20:08:55 +02:00
Separate pipelines for each service
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
version: 0.2
|
||||
phases:
|
||||
pre_build:
|
||||
commands:
|
||||
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
|
||||
- TAG=$(echo $GIT_COMMIT_ID | head -c 8)
|
||||
- IMAGE_URI=$REPO_URI:$TAG
|
||||
build:
|
||||
commands:
|
||||
- docker build -t $IMAGE_URI -f server.Dockerfile .
|
||||
post_build:
|
||||
commands:
|
||||
- docker push $IMAGE_URI
|
||||
- printf '{"ImageUri":"%s"}' $IMAGE_URI > build.json
|
||||
artifacts:
|
||||
files: build.json
|
@@ -1,22 +0,0 @@
|
||||
version: 0.2
|
||||
phases:
|
||||
pre_build:
|
||||
commands:
|
||||
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
|
||||
- TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | head -c 8)
|
||||
- IMAGE_SERVER_URI=$REPO_SERVER_URI:$TAG
|
||||
- IMAGE_CACHE_URI=$REPO_CACHE_URI:$TAG
|
||||
- IMAGE_DB_URI=$REPO_DB_URI:$TAG
|
||||
build:
|
||||
commands:
|
||||
- docker build -t $IMAGE_SERVER_URI -f server.Dockerfile .
|
||||
- docker build -t $IMAGE_CACHE_URI -f cache.Dockerfile .
|
||||
- docker build -t $IMAGE_DB_URI -f database.Dockerfile .
|
||||
post_build:
|
||||
commands:
|
||||
- docker push $IMAGE_SERVER_URI
|
||||
- docker push $IMAGE_CACHE_URI
|
||||
- docker push $IMAGE_DB_URI
|
||||
- printf '{"ImageServerUri":"%s", "ImageCacheUri":"%s", "ImageDatabaseUri":"%s"}' $IMAGE_SERVER_URI $IMAGE_CACHE_URI $IMAGE_DB_URI > build.json
|
||||
artifacts:
|
||||
files: build.json
|
@@ -170,15 +170,31 @@ Resources:
|
||||
Properties:
|
||||
Artifacts:
|
||||
Type: CODEPIPELINE
|
||||
ServiceRole: !Ref CodeBuildServiceRole
|
||||
Source:
|
||||
Type: CODEPIPELINE
|
||||
BuildSpec: |
|
||||
version: 0.2
|
||||
phases:
|
||||
pre_build:
|
||||
commands:
|
||||
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
|
||||
- TAG=$(echo $GIT_COMMIT_ID | head -c 8)
|
||||
- IMAGE_URI=$REPO_URI:$TAG
|
||||
build:
|
||||
commands:
|
||||
- docker build -t $IMAGE_URI -f server.Dockerfile .
|
||||
post_build:
|
||||
commands:
|
||||
- docker push $IMAGE_URI
|
||||
- printf '{"ImageUri":"%s"}' $IMAGE_URI > build.json
|
||||
artifacts:
|
||||
files: build.json
|
||||
Environment:
|
||||
ComputeType: BUILD_GENERAL1_SMALL
|
||||
Image: aws/codebuild/standard:5.0
|
||||
Type: LINUX_CONTAINER
|
||||
PrivilegedMode: true
|
||||
Source:
|
||||
Type: CODEPIPELINE
|
||||
BuildSpec: deployments/buildspec/service.yml
|
||||
ServiceRole: !Ref CodeBuildServiceRole
|
||||
|
||||
# Create three pipelines for the three services
|
||||
# Server pipeline
|
||||
|
@@ -19,14 +19,20 @@ Resources:
|
||||
# Create ECR respositories to hold built docker images
|
||||
ServerRepository:
|
||||
Type: AWS::ECR::Repository
|
||||
DeletionPolicy: Retain
|
||||
UpdateReplacePolicy: Retain
|
||||
Properties:
|
||||
RepositoryName: !Sub ${EnvironmentName}-server
|
||||
CacheRepository:
|
||||
Type: AWS::ECR::Repository
|
||||
DeletionPolicy: Retain
|
||||
UpdateReplacePolicy: Retain
|
||||
Properties:
|
||||
RepositoryName: !Sub ${EnvironmentName}-cache
|
||||
DatabaseRepository:
|
||||
Type: AWS::ECR::Repository
|
||||
DeletionPolicy: Retain
|
||||
UpdateReplacePolicy: Retain
|
||||
Properties:
|
||||
RepositoryName: !Sub ${EnvironmentName}-database
|
||||
|
||||
@@ -161,6 +167,8 @@ Resources:
|
||||
# While the build is in progress we need a place to store artifacts
|
||||
ArtifactBucket:
|
||||
Type: AWS::S3::Bucket
|
||||
DeletionPolicy: Retain
|
||||
UpdateReplacePolicy: Retain
|
||||
Properties:
|
||||
BucketName: !Sub ${EnvironmentName}-${AWS::AccountId}
|
||||
|
||||
@@ -170,15 +178,37 @@ Resources:
|
||||
Properties:
|
||||
Artifacts:
|
||||
Type: CODEPIPELINE
|
||||
ServiceRole: !Ref CodeBuildServiceRole
|
||||
Source:
|
||||
Type: CODEPIPELINE
|
||||
BuildSpec: |
|
||||
version: 0.2
|
||||
phases:
|
||||
pre_build:
|
||||
commands:
|
||||
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
|
||||
- TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | head -c 8)
|
||||
- IMAGE_SERVER_URI=$REPO_SERVER_URI:$TAG
|
||||
- IMAGE_CACHE_URI=$REPO_CACHE_URI:$TAG
|
||||
- IMAGE_DB_URI=$REPO_DB_URI:$TAG
|
||||
build:
|
||||
commands:
|
||||
- docker build -t $IMAGE_SERVER_URI -f server.Dockerfile .
|
||||
- docker build -t $IMAGE_CACHE_URI -f cache.Dockerfile .
|
||||
- docker build -t $IMAGE_DB_URI -f database.Dockerfile .
|
||||
post_build:
|
||||
commands:
|
||||
- docker push $IMAGE_SERVER_URI
|
||||
- docker push $IMAGE_CACHE_URI
|
||||
- docker push $IMAGE_DB_URI
|
||||
- printf '{"ImageServerUri":"%s", "ImageCacheUri":"%s", "ImageDatabaseUri":"%s"}' $IMAGE_SERVER_URI $IMAGE_CACHE_URI $IMAGE_DB_URI > build.json
|
||||
artifacts:
|
||||
files: build.json
|
||||
Environment:
|
||||
ComputeType: BUILD_GENERAL1_SMALL
|
||||
Image: aws/codebuild/standard:5.0
|
||||
Type: LINUX_CONTAINER
|
||||
PrivilegedMode: true
|
||||
Source:
|
||||
Type: CODEPIPELINE
|
||||
BuildSpec: deployments/buildspec/services-all.yml
|
||||
ServiceRole: !Ref CodeBuildServiceRole
|
||||
|
||||
# This pipeline defines the steps to build, deploy, and release the application
|
||||
Pipeline:
|
||||
|
@@ -151,7 +151,7 @@ Resources:
|
||||
RabbitURLParameter:
|
||||
Type: AWS::SSM::Parameter
|
||||
Properties:
|
||||
Name: !Sub /microservices/${EnvironmentName}/rabbiturl
|
||||
Name: /Microservices/RabbitUrl
|
||||
Type: String
|
||||
Description: A connection string for RabbitMQ
|
||||
Value:
|
||||
@@ -162,7 +162,7 @@ Resources:
|
||||
PostgresURLParameter:
|
||||
Type: AWS::SSM::Parameter
|
||||
Properties:
|
||||
Name: !Sub /microservices/${EnvironmentName}/postgresurl
|
||||
Name: /Microservices/PostgresUrl
|
||||
Type: String
|
||||
Description: A connection string for Postgres
|
||||
Value:
|
||||
@@ -173,7 +173,7 @@ Resources:
|
||||
RedisURLParameter:
|
||||
Type: AWS::SSM::Parameter
|
||||
Properties:
|
||||
Name: !Sub /microservices/${EnvironmentName}/redisurl
|
||||
Name: /Microservices/RedisUrl
|
||||
Type: String
|
||||
Description: A connection string for Redis
|
||||
Value: !Sub ${Redis.RedisEndpoint.Address}:${Redis.RedisEndpoint.Port}
|
||||
|
@@ -68,9 +68,9 @@ Resources:
|
||||
awslogs-stream-prefix: !Ref 'ServiceName'
|
||||
Environment:
|
||||
- Name: RABBIT_URL
|
||||
Value: !Sub '{{resolve:ssm:/microservices/${EnvironmentName}/rabbiturl}}'
|
||||
Value: '{{resolve:ssm:/Microservices/RabbitUrl}}'
|
||||
- Name: REDIS_URL
|
||||
Value: !Sub '{{resolve:ssm:/microservices/${EnvironmentName}/redisurl}}'
|
||||
Value: '{{resolve:ssm:/Microservices/RedisUrl}}'
|
||||
|
||||
# The service. The service is a resource which allows you to run multiple
|
||||
# copies of a type of task, and gather up their logs and metrics, as well
|
||||
|
@@ -68,9 +68,9 @@ Resources:
|
||||
awslogs-stream-prefix: !Ref 'ServiceName'
|
||||
Environment:
|
||||
- Name: RABBIT_URL
|
||||
Value: !Sub '{{resolve:ssm:/microservices/${EnvironmentName}/rabbiturl}}'
|
||||
Value: '{{resolve:ssm:/Microservices/RabbitUrl}}'
|
||||
- Name: POSTGRES_URL
|
||||
Value: !Sub '{{resolve:ssm:/microservices/${EnvironmentName}/postgresurl}}'
|
||||
Value: '{{resolve:ssm:/Microservices/PostgresUrl}}'
|
||||
|
||||
# The service. The service is a resource which allows you to run multiple
|
||||
# copies of a type of task, and gather up their logs and metrics, as well
|
||||
|
@@ -86,9 +86,9 @@ Resources:
|
||||
awslogs-stream-prefix: !Ref 'ServiceName'
|
||||
Environment:
|
||||
- Name: RABBIT_URL
|
||||
Value: !Sub '{{resolve:ssm:/microservices/${EnvironmentName}/rabbiturl}}'
|
||||
Value: '{{resolve:ssm:/Microservices/RabbitUrl}}'
|
||||
- Name: REDIS_URL
|
||||
Value: !Sub '{{resolve:ssm:/microservices/${EnvironmentName}/redisurl}}'
|
||||
Value: '{{resolve:ssm:/Microservices/RedisUrl}}'
|
||||
- Name: SERVER_ADDR
|
||||
Value: 0.0.0.0:80
|
||||
|
||||
|
@@ -73,9 +73,9 @@ Resources:
|
||||
awslogs-stream-prefix: !Ref 'ServiceName'
|
||||
Environment:
|
||||
- Name: RABBIT_URL
|
||||
Value: !Sub '{{resolve:ssm:/microservices/${EnvironmentName}/rabbiturl}}'
|
||||
Value: '{{resolve:ssm:/Microservices/RabbitUrl}}'
|
||||
- Name: REDIS_URL
|
||||
Value: !Sub '{{resolve:ssm:/microservices/${EnvironmentName}/redisurl}}'
|
||||
Value: '{{resolve:ssm:/Microservices/RedisUrl}}'
|
||||
|
||||
# The service. The service is a resource which allows you to run multiple
|
||||
# copies of a type of task, and gather up their logs and metrics, as well
|
||||
|
@@ -73,9 +73,9 @@ Resources:
|
||||
awslogs-stream-prefix: !Ref 'ServiceName'
|
||||
Environment:
|
||||
- Name: RABBIT_URL
|
||||
Value: !Sub '{{resolve:ssm:/microservices/${EnvironmentName}/rabbiturl}}'
|
||||
Value: '{{resolve:ssm:/Microservices/RabbitUrl}}'
|
||||
- Name: POSTGRES_URL
|
||||
Value: !Sub '{{resolve:ssm:/microservices/${EnvironmentName}/postgresurl}}'
|
||||
Value: '{{resolve:ssm:/Microservices/PostgresUrl}}'
|
||||
|
||||
# The service. The service is a resource which allows you to run multiple
|
||||
# copies of a type of task, and gather up their logs and metrics, as well
|
||||
|
@@ -91,9 +91,9 @@ Resources:
|
||||
awslogs-stream-prefix: !Ref 'ServiceName'
|
||||
Environment:
|
||||
- Name: RABBIT_URL
|
||||
Value: !Sub '{{resolve:ssm:/microservices/${EnvironmentName}/rabbiturl}}'
|
||||
Value: '{{resolve:ssm:/Microservices/RabbitUrl}}'
|
||||
- Name: REDIS_URL
|
||||
Value: !Sub '{{resolve:ssm:/microservices/${EnvironmentName}/redisurl}}'
|
||||
Value: '{{resolve:ssm:/Microservices/RedisUrl}}'
|
||||
- Name: SERVER_ADDR
|
||||
Value: 0.0.0.0:80
|
||||
|
||||
|
Reference in New Issue
Block a user