mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-22 07:45:49 +00:00
Adding buildspec file
This commit is contained in:
parent
8b8304fa25
commit
112d405d34
3 changed files with 158 additions and 0 deletions
11
Dockerfile
Normal file
11
Dockerfile
Normal file
|
@ -0,0 +1,11 @@
|
|||
FROM openjdk:17-jdk
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY build/libs/spring-petclinic-3.2.0.jar /app/app.jar
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ENTRYPOINT ["java"]
|
||||
|
||||
CMD ["-jar", "app.jar"]
|
27
buildspec.yml
Normal file
27
buildspec.yml
Normal file
|
@ -0,0 +1,27 @@
|
|||
version: 0.2
|
||||
|
||||
phases:
|
||||
install:
|
||||
runtime-versions:
|
||||
java: corretto11
|
||||
pre_build:
|
||||
commands:
|
||||
- echo Pre-build phase...
|
||||
- echo Compile and running tests using Gradle Wrapper...
|
||||
- chmod +x gradlew
|
||||
- ./gradlew build
|
||||
build:
|
||||
commands:
|
||||
- echo Build phase...
|
||||
- echo Build Docker image and tag it...
|
||||
- docker build -t bryanvalencia94/petclinic:$CODEBUILD_BUILD_NUMBER .
|
||||
post_build:
|
||||
commands:
|
||||
- echo Post-build phase...
|
||||
- echo Push Docker image to repository...
|
||||
- docker push bryanvalencia94/petclinic:$CODEBUILD_BUILD_NUMBER
|
||||
|
||||
#artifacts:
|
||||
# files:
|
||||
# - '**/*'
|
||||
# name: DevOpsAppArtifacts
|
120
cloud-formation-template.yaml
Normal file
120
cloud-formation-template.yaml
Normal file
|
@ -0,0 +1,120 @@
|
|||
Resources:
|
||||
SecurityGroupPetClinic:
|
||||
Type: "AWS::EC2::SecurityGroup"
|
||||
Properties:
|
||||
GroupName: "SecurityGroupPetClinic"
|
||||
GroupDescription: "Security group to allow SSH and HTTP over 8080"
|
||||
VpcId: "vpc-fe0d6d84"
|
||||
SecurityGroupEgress:
|
||||
- IpProtocol: "-1"
|
||||
CidrIp: 0.0.0.0/0
|
||||
SecurityGroupIngress:
|
||||
- IpProtocol: tcp
|
||||
FromPort: 22
|
||||
ToPort: 22
|
||||
CidrIp: 0.0.0.0/0
|
||||
- IpProtocol: tcp
|
||||
FromPort: 8080
|
||||
ToPort: 8080
|
||||
CidrIp: 0.0.0.0/0
|
||||
- IpProtocol: tcp
|
||||
FromPort: 80
|
||||
ToPort: 80
|
||||
CidrIp: 0.0.0.0/0
|
||||
|
||||
LaunchConfigurationPetClinic2:
|
||||
Type: "AWS::AutoScaling::LaunchConfiguration"
|
||||
Properties:
|
||||
ImageId: "ami-04c97e62cb19d53f1"
|
||||
InstanceType: "t4g.small"
|
||||
KeyName: "devops-keypair"
|
||||
LaunchConfigurationName: "LaunchConfigurationPetClinic2"
|
||||
SecurityGroups:
|
||||
- !GetAtt SecurityGroupPetClinic.GroupId
|
||||
UserData:
|
||||
Fn::Base64:
|
||||
!Sub |
|
||||
#!/bin/bash
|
||||
sudo yum update -y
|
||||
sudo yum install docker -y
|
||||
sudo service docker start
|
||||
sudo docker pull bryanvalencia94/petclinic:1.0.0-mac-arm
|
||||
sudo docker run -p 8080:8080 bryanvalencia94/petclinic:1.0.0-mac-arm
|
||||
|
||||
AutoScalingGroupPetClinic:
|
||||
Type: "AWS::AutoScaling::AutoScalingGroup"
|
||||
Properties:
|
||||
MaxSize: 2
|
||||
MinSize: 1
|
||||
LaunchConfigurationName:
|
||||
!Ref LaunchConfigurationPetClinic2
|
||||
VPCZoneIdentifier:
|
||||
- subnet-3da0f161
|
||||
- subnet-3304e07e
|
||||
TargetGroupARNs:
|
||||
- Ref: TargetGroupPetClinic
|
||||
|
||||
AutoScalingPolicyPetClinic:
|
||||
Type: AWS::AutoScaling::ScalingPolicy
|
||||
Properties:
|
||||
AdjustmentType: "ChangeInCapacity"
|
||||
AutoScalingGroupName:
|
||||
!Ref AutoScalingGroupPetClinic
|
||||
Cooldown: "300"
|
||||
ScalingAdjustment: "1"
|
||||
|
||||
LoadBalancerPetClinic:
|
||||
Type: "AWS::ElasticLoadBalancingV2::LoadBalancer"
|
||||
Properties:
|
||||
Name: LoadBalancerPetClinic
|
||||
Subnets:
|
||||
- subnet-3da0f161
|
||||
- subnet-3304e07e
|
||||
SecurityGroups:
|
||||
- !Ref SecurityGroupPetClinic
|
||||
Type: application
|
||||
|
||||
TargetGroupPetClinic:
|
||||
Type: "AWS::ElasticLoadBalancingV2::TargetGroup"
|
||||
Properties:
|
||||
Name: TargetGroupPetClinic
|
||||
Port: 8080
|
||||
Protocol: HTTP
|
||||
VpcId: "vpc-fe0d6d84"
|
||||
TargetType: instance
|
||||
|
||||
ListenerPetClinic:
|
||||
Type: "AWS::ElasticLoadBalancingV2::Listener"
|
||||
Properties:
|
||||
DefaultActions:
|
||||
- Type: forward
|
||||
TargetGroupArn:
|
||||
Ref: TargetGroupPetClinic
|
||||
LoadBalancerArn:
|
||||
Ref: LoadBalancerPetClinic
|
||||
Port: 80
|
||||
Protocol: HTTP
|
||||
|
||||
CloudFrontDistributionPetClinic:
|
||||
Type: "AWS::CloudFront::Distribution"
|
||||
Properties:
|
||||
DistributionConfig:
|
||||
DefaultCacheBehavior:
|
||||
TargetOriginId: LoadBalancerOrigin
|
||||
ViewerProtocolPolicy: allow-all
|
||||
CachePolicyId: 658327ea-f89d-4fab-a63d-7e88639e58f6 # This is the AWS Managed CacheOptimized CachePolicyId
|
||||
Enabled: true
|
||||
Origins:
|
||||
- CustomOriginConfig:
|
||||
HTTPPort: 80
|
||||
OriginProtocolPolicy: http-only
|
||||
DomainName: !GetAtt LoadBalancerPetClinic.DNSName
|
||||
Id: LoadBalancerOrigin
|
||||
|
||||
Outputs:
|
||||
LoadBalancerDNSName:
|
||||
Description: The DNS name of the load balancer.
|
||||
Value:
|
||||
Fn::GetAtt:
|
||||
- LoadBalancerPetClinic
|
||||
- DNSName
|
Loading…
Reference in a new issue