{"id":1501,"date":"2019-03-12T21:24:21","date_gmt":"2019-03-12T12:24:21","guid":{"rendered":"https:\/\/esoro.jp\/?p=1501"},"modified":"2020-10-20T07:38:09","modified_gmt":"2020-10-19T22:38:09","slug":"aws-codepipeline%e3%81%a7springboot%e3%82%a2%e3%83%97%e3%83%aa%e3%82%92ecs%e3%81%b8%e3%83%87%e3%83%97%e3%83%ad%e3%82%a4%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f","status":"publish","type":"post","link":"https:\/\/esoro.jp\/?p=1501","title":{"rendered":"AWS CodePipeline\u3067springboot\u30a2\u30d7\u30ea\u3092ECS\u3078\u30c7\u30d7\u30ed\u30a4\u3057\u3066\u307f\u305f"},"content":{"rendered":"<p>\u30aa\u30f3\u30d7\u30ec\u30b5\u30fc\u30d0\u3067\u7a3c\u50cd\u3057\u3066\u3044\u308b\u30b7\u30b9\u30c6\u30e0\u3092AWS\u3078\u79fb\u884c\u3057\u305f\u3044\u3068\u3044\u3046\u8a71\u304c\u3042\u308a\u3001AWS\u74b0\u5883\u3067CI\/CD\u304c\u3069\u3046\u51fa\u6765\u308b\u304b\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n\u69cb\u6210\u3068\u3057\u3066\u306f\u3001\u958b\u767a\u7528\u7aef\u672b\u306eIDE\uff08IntelliJ IDEA\uff09\u3067\u30b3\u30df\u30c3\u30c8\u3001CodeCommit\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u30d7\u30c3\u30b7\u30e5\u3057\u305f\u3089\u3001Maven\u30d3\u30eb\u30c9\u3092\u958b\u59cb\u3057\u3066ECR\u3078\u30b3\u30f3\u30c6\u30ca\u3092\u30d7\u30c3\u30b7\u30e5\u3001ECS\u3078\u30c7\u30d7\u30ed\u30a4\u3068\u3044\u3046\u6d41\u308c\u3067\u3059\u3002<\/p>\n<p>\u4e0b\u8a18AWS\u74b0\u5883\u3092\u7528\u610f\u3057\u307e\u3059\u3002<br \/>\n\u30fbECS\u306e\u8a2d\u5b9a\uff08\u30af\u30e9\u30b9\u30bf\u3001\u30b5\u30fc\u30d3\u30b9\u3001\u30bf\u30b9\u30af\u5b9a\u7fa9\uff09<br \/>\n\u30fbECR\u306b\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u4f5c\u6210\u3001springboot\u306e\u30a2\u30d7\u30ea\u306a\u306e\u3067openjdk\u306e\u30a4\u30e1\u30fc\u30b8\u3092\u30d7\u30c3\u30b7\u30e5<br \/>\n\u30fbCodeCommit\u306b\u30ea\u30dd\u30b8\u30c8\u30ea\u4f5c\u6210<br \/>\n\u30fbCodePipeline\u3092\u8a2d\u5b9a<\/p>\n<p>\u30b0\u30b0\u308c\u3070\u3001\u3044\u308d\u3044\u308dAWS\u306b\u95a2\u3059\u308b\u60c5\u5831\u306f\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u306a\u304b\u306a\u304b\u3046\u307e\u304f\u51fa\u6765\u307e\u305b\u3093\u3002<br \/>\n\u3067\u3001\u3044\u308d\u3044\u308d\u3084\u3063\u3066\u307f\u305f\u7d50\u679c\u3001\u30d3\u30eb\u30c9\u7528\u306bbuildspec.yml\u3001\u30c7\u30d7\u30ed\u30a4\u7528\u306bDockerfile\u3092\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u76f4\u4e0b\u306b\u7f6e\u304f\u3068\u30c7\u30d7\u30ed\u30a4\u304c\u6210\u529f\u3057\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"lang:yaml decode:true \" title=\"buildspec.yml\" >version: 0.2\r\n\r\nphases:\r\n  pre_build:\r\n    commands:\r\n      - echo Logging in to Amazon ECR...\r\n      - aws --version\r\n      - $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email)\r\n      - REPOSITORY_URI={AWS\u4e0a\u306eECR\u30ea\u30dd\u30b8\u30c8\u30ea}\r\n      - COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)\r\n      - IMAGE_TAG=${COMMIT_HASH:=latest}\r\n  build:\r\n    commands:\r\n      - echo Build started on `date`\r\n      - mvn clean\r\n      - mvn install\r\n      - echo Building the Docker image...          \r\n      - docker build -t $REPOSITORY_URI:latest .\r\n      - docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG\r\n  post_build:\r\n    commands:\r\n      - echo Build completed on `date`\r\n      - mvn package\r\n      - echo Pushing the Docker images...\r\n      - docker push $REPOSITORY_URI:latest\r\n      - docker push $REPOSITORY_URI:$IMAGE_TAG\r\n      - echo Writing image definitions file...\r\n      - printf '[{\"name\":\"sample-app\",\"imageUri\":\"%s\"}]' $REPOSITORY_URI:$IMAGE_TAG &gt; imagedefinitions.json      \r\nartifacts:\r\n  files:\r\n    - imagedefinitions.json<\/pre>\n<pre class=\"lang:yaml decode:true \" title=\"Dockerfile\" >FROM openjdk:latest\r\nVOLUME \/tmp\r\nADD target\/springtest-0.0.1-SNAPSHOT.jar app.jar\r\nEXPOSE 5000\r\nENV JAVA_OPTS=\"\"\r\nENTRYPOINT [ \"sh\", \"-c\", \"java $JAVA_OPTS -Djava.security.egd=file:\/dev\/.\/urandom -jar \/app.jar\" ] \r\n<\/pre>\n<p>\u3059\u3044\u307e\u305b\u3093\u3001\u60c5\u5831\u306e\u53c2\u7167\u5143\u304c\u89e3\u3089\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002\u3002<br \/>\nmvn install\u3000\u7d50\u69cb\u6642\u9593\u639b\u304b\u308a\u307e\u3059\u306d\u3002\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/esoro.jp\/wordpress\/wp-content\/uploads\/2019\/03\/pipe.png\" alt=\"\" width=\"1562\" height=\"817\" class=\"aligncenter size-full wp-image-1504\" srcset=\"https:\/\/esoro.jp\/wordpress\/wp-content\/uploads\/2019\/03\/pipe.png 1562w, https:\/\/esoro.jp\/wordpress\/wp-content\/uploads\/2019\/03\/pipe-300x157.png 300w, https:\/\/esoro.jp\/wordpress\/wp-content\/uploads\/2019\/03\/pipe-768x402.png 768w, https:\/\/esoro.jp\/wordpress\/wp-content\/uploads\/2019\/03\/pipe-1024x536.png 1024w, https:\/\/esoro.jp\/wordpress\/wp-content\/uploads\/2019\/03\/pipe-500x262.png 500w\" sizes=\"(max-width: 1562px) 100vw, 1562px\" \/><\/p>\n<p>AWS\u306f\u6570\u5e74\u524d\u306b\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u767b\u9332\u3057\u3066\u3061\u3087\u3053\u3063\u3068\u3060\u3051\u904a\u3093\u3067\u307f\u305f\u3060\u3051\u3060\u3063\u305f\u306e\u3067\u3001\u3061\u3083\u3093\u3068AWS\u74b0\u5883\u3092\u7406\u89e3\u3057\u305f\u4e0a\u3067\u6574\u7406\u3057\u3066\u304b\u3089\u3058\u3083\u306a\u3044\u3068\u5b9f\u5229\u7528\u306b\u306f\u9060\u3044\u611f\u3058\u3067\u3059\u3002\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30aa\u30f3\u30d7\u30ec\u30b5\u30fc\u30d0\u3067\u7a3c\u50cd\u3057\u3066\u3044\u308b\u30b7\u30b9\u30c6\u30e0\u3092AWS\u3078\u79fb\u884c\u3057\u305f\u3044\u3068\u3044\u3046\u8a71\u304c\u3042\u308a\u3001AWS\u74b0 &hellip; <a href=\"https:\/\/esoro.jp\/?p=1501\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,17],"tags":[],"_links":{"self":[{"href":"https:\/\/esoro.jp\/index.php?rest_route=\/wp\/v2\/posts\/1501"}],"collection":[{"href":"https:\/\/esoro.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/esoro.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/esoro.jp\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/esoro.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1501"}],"version-history":[{"count":0,"href":"https:\/\/esoro.jp\/index.php?rest_route=\/wp\/v2\/posts\/1501\/revisions"}],"wp:attachment":[{"href":"https:\/\/esoro.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1501"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/esoro.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1501"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/esoro.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1501"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}