Açıklaması şöyle
AWS CodeDeploy and AWS CodePipeline are two AWS deployment services. AWS CodeDeploy automates the deployment of code to an EC2 instance. After we commit any changes to a specific branch, CodePipeline builds, tests, and deploys our application.Adımlar şöyle
The basic steps are below:1. Prepare Spring boot application and push it to GitHub
2. Setup IAM role. We will need two IAM role. Role for EC2 and Code deploy. EC2 role will require S3 and code deploy permission.
3. Launch EC2 instance
4. Create application in code deploy
5. Setup code pipeline
IAM ve geri kalan her tüm ekranları gösteren bir örnek burada
Projeyi yapılandırır
Örnek
Şöyle yaparız. Burada JDK 11 Correto ve maven kullanılıyor
version: 0.2phases:install:runtime-versions:java: corretto11build:commands:- mvn clean installpost_build:commands:- echo Build completedartifacts:files:- target/*.jar- scripts/*.sh- appspec.ymldiscard-paths: yes
appspec.yml
Örnek
Şöyle yaparız.
version: 0.0 os: linux files: - source: / destination: /home/ec2-user/server permissions: - object: / pattern: "**" owner: ec2-user group: ec2-user hooks: BeforeInstall: - location: server_clear.sh timeout: 300 runas: ec2-user AfterInstall: - location: fix_privileges.sh timeout: 300 runas: ec2-user ApplicationStart: - location: server_start.sh timeout: 20 runas: ec2-user ApplicationStop: - location: server_stop.sh timeout: 20 runas: ec2-user
Açıklaması şöyle
This will copy files to /home/ec2-user/server folder that I mentioned in the artifacts part of the buildspec.yml. Hooks allow us to run different scripts at different stages of the deployment. In the start script, I added the command to run the jar and open port 80 so we can access the API.
Hiç yorum yok:
Yorum Gönder