{"id":1121,"date":"2019-05-25T15:04:12","date_gmt":"2019-05-25T12:04:12","guid":{"rendered":"https:\/\/artem.services\/?p=1121"},"modified":"2019-05-25T15:07:12","modified_gmt":"2019-05-25T12:07:12","slug":"aws-codecommit-%d0%b8-codebuild-%d1%81%d0%be%d0%b1%d0%b8%d1%80%d0%b0%d0%b5%d0%bc-docker-%d0%be%d0%b1%d1%80%d0%b0%d0%b7-%d0%b8-%d0%bf%d1%83%d1%88%d0%b0%d0%b5%d0%bc-%d0%b5%d0%b3%d0%be-%d0%b2-ecr","status":"publish","type":"post","link":"https:\/\/artem.services\/?p=1121","title":{"rendered":"AWS &#8212; CodeCommit \u0438 CodeBuild \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c Docker \u043e\u0431\u0440\u0430\u0437 \u0438 \u043f\u0443\u0448\u0430\u0435\u043c \u0435\u0433\u043e \u0432 ECR"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-214\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo.png\" alt=\"\" width=\"975\" height=\"450\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo.png 975w, https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo-300x138.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo-768x354.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo-954x440.png 954w\" sizes=\"(max-width: 975px) 100vw, 975px\" \/><\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0432 <strong>CodeCommit<\/strong> \u0438 \u0441\u0431\u043e\u0440\u043a\u0443 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e <strong>Docker<\/strong> \u043e\u0431\u0440\u0430\u0437\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <strong>CodeBuild<\/strong> \u0438 \u0437\u0430\u043f\u0443\u0448\u0430\u0435\u043c \u0435\u0433\u043e \u0432 <strong>ECR<\/strong>.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 <strong>CodeCommit<\/strong> \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439. \u0418\u043c\u044f \u043c\u043e\u0435\u0433\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f &#8212; &quot;<strong>artem-test<\/strong>&quot;<\/p>\n<blockquote><p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u043c \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u0443 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d <strong>SSH<\/strong> \u043a\u043b\u044e\u0447. \u0415\u0441\u043b\u0438 \u0443\u0436\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0435\u0433\u043e <strong>ID<\/strong>, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u0435\u043d.<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>\u041a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u043c \u0441\u0435\u0431\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ngit clone ssh:\/\/YOUR_ID_FOR_SSH_KEY@git-codecommit.us-east-1.amazonaws.com\/v1\/repos\/artem-test\r\n<\/pre>\n<p>&nbsp;<\/p>\n<blockquote><p>\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0440\u0435\u0433\u0438\u043e\u043d, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u043d \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439.<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043d\u0435\u0433\u043e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e <strong>Dockerfile<\/strong><\/p>\n<h3>Dockerfile:<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nFROM php:7.1-apache-jessie\r\n\r\nRUN apt update &amp;&amp; \\\r\n    apt install curl net-tools &amp;&amp; \\\r\n    apt-get clean\r\n\r\nCMD [&quot;apache2-foreground&quot;]\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\u0414\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c: <strong>buildspec.yml<\/strong><\/p>\n<h3>buildspec.yml:<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nversion: 0.2\r\n\r\nenv:\r\n  variables:\r\n    AWS_ACCOUNT_ID: &quot;XXXXXXXXXXXX&quot;\r\n    AWS_DEFAULT_REGION: &quot;us-east-1&quot;\r\n    IMAGE_REPO_NAME: &quot;artem-test&quot;\r\n    IMAGE_TAG: &quot;latest&quot;\r\n\r\nphases:\r\n  install:\r\n    runtime-versions:\r\n      docker: 18\r\n  pre_build:\r\n    commands:\r\n      - echo Logging in to Amazon ECR...\r\n      - $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION)\r\n  build:\r\n    commands:\r\n      - echo Build started on `date`\r\n      - echo Building the Docker image...          \r\n      - docker build -t $IMAGE_REPO_NAME:$IMAGE_TAG .\r\n      - docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com\/$IMAGE_REPO_NAME:$IMAGE_TAG \r\n  post_build:\r\n    commands:\r\n      - echo Build completed on `date`\r\n      - echo Pushing the Docker image...\r\n      - docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com\/$IMAGE_REPO_NAME:$IMAGE_TAG\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\u041e\u0442\u043f\u0440\u0430\u0432\u0438\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ngit add .\r\ngit commit -am &quot;git init&quot;\r\ngit push\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u0432 <strong>CodeBuild<\/strong>, \u0443\u043a\u0430\u0437\u0430\u0432 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0432 <strong>CodeCommit<\/strong>.<\/p>\n<p>\u0414\u0430\u0434\u0438\u043c \u0434\u043b\u044f <strong>CodeBuild<\/strong> \u043f\u0440\u0430\u0432\u0430 \u0432 <strong>ECR<\/strong><\/p>\n<p>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c <strong>IAM<\/strong> -&gt; <strong>CodeBuild<\/strong><\/p>\n<p>\u0418\u0449\u0435\u043c &quot;<strong>codebuild-artem-test-service-role<\/strong>&quot;<\/p>\n<p>\u0418 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u044d\u0442\u043e\u0439 \u0440\u043e\u043b\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e <strong>Policy<\/strong>:<\/p>\n<pre>AmazonEC2ContainerRegistryPowerUser<\/pre>\n<p>&nbsp;<\/p>\n<p>\u0414\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043b\u043e\u0433\u043e\u0432 \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0441\u0435\u0440\u0432\u0438\u0441 &quot;<strong>CloudWatch<\/strong>&quot; \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0433\u0440\u0443\u043f\u043f\u0443. \u0422\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c <strong>S3 Bucket<\/strong> \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0430\u0440\u0445\u0438\u0432\u043e\u0432 \u043b\u043e\u0433\u043e\u0432.<\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0437 \u0432 <strong>CodeBuild<\/strong>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0432 CodeCommit \u0438 \u0441\u0431\u043e\u0440\u043a\u0443 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e Docker \u043e\u0431\u0440\u0430\u0437\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 CodeBuild \u0438 \u0437\u0430\u043f\u0443\u0448\u0430\u0435\u043c \u0435\u0433\u043e \u0432 ECR. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 CodeCommit \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439. \u0418\u043c\u044f \u043c\u043e\u0435\u0433\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f &#8212; &quot;artem-test&quot; \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u043c \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u0443 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d SSH \u043a\u043b\u044e\u0447. \u0415\u0441\u043b\u0438 \u0443\u0436\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0435\u0433\u043e ID, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u0435\u043d. &nbsp; \u041a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u043c &hellip; <a href=\"https:\/\/artem.services\/?p=1121\" class=\"more-link\">\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u044c<span class=\"screen-reader-text\"> &quot;AWS &#8212; CodeCommit \u0438 CodeBuild \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c Docker \u043e\u0431\u0440\u0430\u0437 \u0438 \u043f\u0443\u0448\u0430\u0435\u043c \u0435\u0433\u043e \u0432 ECR&quot;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[24,37],"tags":[25,867,865,863,811,869],"_links":{"self":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1121"}],"collection":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1121"}],"version-history":[{"count":5,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1121\/revisions"}],"predecessor-version":[{"id":1126,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1121\/revisions\/1126"}],"wp:attachment":[{"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}