質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
docker-compose

docker-composeとは、複数のコンテナで構成されるサービスを提供する手順を自動的し管理を簡単にするツール。composeファイルを使用しコマンド1回で設定した全サービスを作成・起動することが可能です。

Jenkins

Jenkinsとは、Apache TomcatなどのServletで動作しているサーバーベースシステムです。Jenkinsはオープンソースであり、LInux,Mac OS X,Windows,Solaris,FreeBSDとOpenBSDのためのパッケージがあります。

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Apache Maven

Apache Mavenは、ソフトウェアプロジェクトの管理ツールです。

Q&A

解決済

1回答

2248閲覧

jenkinsで新規JOBを作成してwebアプリケーションがデプロイできない

h.sekiguchi

総合スコア11

docker-compose

docker-composeとは、複数のコンテナで構成されるサービスを提供する手順を自動的し管理を簡単にするツール。composeファイルを使用しコマンド1回で設定した全サービスを作成・起動することが可能です。

Jenkins

Jenkinsとは、Apache TomcatなどのServletで動作しているサーバーベースシステムです。Jenkinsはオープンソースであり、LInux,Mac OS X,Windows,Solaris,FreeBSDとOpenBSDのためのパッケージがあります。

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Apache Maven

Apache Mavenは、ソフトウェアプロジェクトの管理ツールです。

0グッド

0クリップ

投稿2019/08/26 10:29

編集2019/08/30 05:53

事象

  • jenkinsで新規JOBを作成してwebアプリケーションをデプロイできない

事象に対して予想していること

  • jenkinsで展開したワークスペースでmvnを実行できる権限がない
  • buildが終わる前に後続のdocker tag~~~が実行されている

事象箇所

jenkins

1Building in workspace /var/lib/jenkins/jobs/xxxxx/workspace 2 > git rev-parse --is-inside-work-tree # timeout=10 3[workspace] $ mvn -f /var/lib/jenkins/jobs/xxxxx/workspace/pom.xml -Dmaven.test.skip=true clean package docker:build 4[INFO] 5[INFO] ------------------------------------------------------------------------ 6[INFO] Building xxxxx 0.0.1-SNAPSHOT 7[INFO] ------------------------------------------------------------------------ 8[INFO] 9[INFO] --- docker-maven-plugin:1.0.0:tag (tag-image) @ APIプロジェクト --- 10[INFO] Using authentication suppliers: [ConfigFileRegistryAuthSupplier] 11[INFO] Creating tag xxxxxx.dkr.ecr.ap-xxxx.amazonaws.com/xxxxx/api from xxxxx/api 12[INFO] ------------------------------------------------------------------------ 13[INFO] BUILD FAILURE 14[INFO] ------------------------------------------------------------------------ 15[INFO] Total time: 9.117 s 16[INFO] Finished at: 2019-08-26T08:54:38Z 17[INFO] Final Memory: 56M/398M 18[INFO] ------------------------------------------------------------------------ 19[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:tag (tag-image) on project APIプロジェクト: Exception caught: Image not found: xxxxx/api: Request error: POST unix://localhost:80/images/xxxxx/api/tag?repo=xxxx.dkr.ecr.ap-xxxx.amazonaws.com%2Fxxxxx%2Fapi: 404, body: {"message":"No such image: xxxxx/api:latest"}: HTTP 404 Not Found -> [Help 1] 20[ERROR] 21[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 22[ERROR] Re-run Maven using the -X switch to enable full debug logging. 23[ERROR] 24[ERROR] For more information about the errors and possible solutions, please read the following articles: 25[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException 26Build step 'Invoke top-level Maven targets' marked build as failure 27Finished: FAILURE

実現したいこと

  • dockerコンテナをjenkinsのJOB経由で開発環境にデプロイしたい

技術まわり

  • AWS-ECS,ECR
  • docker
  • java
  • spring boot
  • jenkins
  • mvn

参考ソース

XML

1POM.xml ※Spring-boot回りの記述は省略しました 2<?xml version="1.0" encoding="UTF-8"?> 3<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 5 <modelVersion>4.0.0</modelVersion> 6 7 <groupId>com.brainlab</groupId> 8 <artifactId>xxxxx-api</artifactId> 9 <version>0.0.1-SNAPSHOT</version> 10 <packaging>jar</packaging> 11 12 <name>xxxxx api</name> 13 <description>API for xxxx </description> 14 15 <parent> 16 <groupId>org.springframework.boot</groupId> 17 <artifactId>spring-boot-starter-parent</artifactId> 18 <version>1.5.8.RELEASE</version> 19 <relativePath/> <!-- lookup parent from repository --> 20 </parent> 21 <distributionManagement> 22 <repository> 23 <id>ixor</id> 24 <name>ixor-releases</name> 25 <url>http://repo.ixor.be/nexus/content/repositories/ixor-releases</url> 26 </repository> 27 <snapshotRepository> 28 <id>ixor</id> 29 <name>ixor-snapshots</name> 30 <url>http://repo.ixor.be/nexus/content/repositories/ixor-snapshots</url> 31 </snapshotRepository> 32 </distributionManagement> 33 <properties> 34 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 35 <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 36 <java.version>1.8</java.version> 37 </properties> 38 39 <build> 40 <finalName>${project.artifactId}</finalName> 41 <plugins> 42 <plugin> 43 <groupId>org.springframework.boot</groupId> 44 <artifactId>spring-boot-maven-plugin</artifactId> 45 </plugin> 46 <plugin> 47 <groupId>org.apache.maven.plugins</groupId> 48 <artifactId>maven-antrun-plugin</artifactId> 49 <executions> 50 <execution> 51 <phase>package</phase> 52 <configuration> 53 <target> 54 <delete dir="${project.basedir}/docker/api/config" /> 55 <mkdir dir="${project.build.directory}/config" /> 56 <mkdir dir="${project.basedir}/docker/api/config" /> 57 <copy todir="${project.build.directory}/config"> 58 <fileset dir="${project.basedir}/config/dev/"> 59 <include name="*.yml" /> 60 </fileset> 61 <fileset dir="${project.basedir}/config/prod/"> 62 <include name="*.yml" /> 63 </fileset> 64 <fileset dir="${project.basedir}/config/stage/"> 65 <include name="*.yml" /> 66 </fileset> 67 <fileset dir="${project.basedir}/config/"> 68 <include name="*.yml" /> 69 </fileset> 70 </copy> 71 <copy todir="${project.basedir}/docker/api/config"> 72 <fileset dir="${project.build.directory}/config" /> 73 </copy> 74 </target> 75 </configuration> 76 <goals> 77 <goal>run</goal> 78 </goals> 79 </execution> 80 </executions> 81 </plugin> 82 <plugin> 83 <groupId>com.spotify</groupId> 84 <artifactId>docker-maven-plugin</artifactId> 85 <version>1.0.0</version> 86 <configuration> 87 <imageName>xxxxx/api</imageName> 88 <baseImage>tesla/base-java</baseImage> 89 <dockerDirectory>docker/api</dockerDirectory> 90 <!-- copy the service's jar file from target into the root directory of the image --> 91 <resources> 92 <resource> 93 <targetPath>/opt/api/</targetPath> 94 <directory>${project.build.directory}</directory> 95 <include>${project.build.finalName}.jar</include> 96 </resource> 97 </resources> 98 </configuration> 99 <executions> 100 <execution> 101 <id>tag-image</id> 102 <phase>package</phase> 103 <goals> 104 <goal>tag</goal> 105 </goals> 106 <configuration> 107 <image>xxxxx/api</image> 108 <newName>xxxxxx.dkr.ecr.xxxxx.amazonaws.com/xxxxx/api</newName> 109 </configuration> 110 </execution> 111 <execution> 112 <id>push-image</id> 113 <phase>install</phase> 114 <goals> 115 <goal>push</goal> 116 </goals> 117 <configuration> 118 <imageName>xxxxx.dkr.ecr.xxxxx.amazonaws.com/xxxxx/api</imageName> 119 </configuration> 120 </execution> 121 </executions> 122 </plugin> 123 </plugins> 124 </build> 125</project>

jenkins

1ビルド定義です 2 3#!/bin/bash -xe 4 5 6BASE_DIR="${WORKSPACE}/" 7 8cd "${BASE_DIR}" 9 10# mvn clean package docker:build -Dmaven.test.skip=true 11 12docker tag aaaaa/api:latest xxxxx.dkr.ecr.ap-xxxxxx.amazonaws.com/aaaaa/api:${VERSION} 13 14 15$(aws ecr get-login --no-include-email --region xx) 16 17docker push xxx.dkr.ecr.ap-xxx.amazonaws.com/xxx:${VERSION} 18 19docker rmi -f xxx.dkr.ecr.ap-xxx.amazonaws.com/xxx:${VERSION} 20 21 22~~ ecs-cli compose -f docker/docker-compose.yml --project-name xxx service up --cluster xxx --deployment-max-percent 200 --deployment-min-healthy-percent 0 23

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

事象原因

  • docker image(docker:build)を作成する前にタグ付け(package)をしようとするが対象のイメージがないため、エラーとなっていた。

改修理由

  • 初回構築はうまくいってこのままでも動くが

jenkinsのビルドでdocker tag もpushもしてるので代替している定義があるのでpom.xmlとしては不要なので削除しておいたほうがいいと指摘を貰った為

xml

1 <executions> 2 <execution> 3 <id>tag-image</id> 4 <phase>package</phase> 5 <goals> 6 <goal>tag</goal> 7 </goals> 8 <configuration> 9 <image>xxx</image> 10 <newName>xx.dkr.ecr.ap-xx.amazonaws.com/xx</newName> 11 </configuration> 12 </execution> 13 <execution> 14 <id>push-image</id> 15 <phase>install</phase> 16 <goals> 17 <goal>push</goal> 18 </goals> 19 <configuration> 20 <imageName>xx.dkr.ecr.ap-xx.amazonaws.com/xx</imageName> 21 </configuration> 22 </execution> 23 </executions> 24 25

投稿2019/08/30 05:49

h.sekiguchi

総合スコア11

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問