docker-training / ddev-labs

Labs for the workshop Docker for Enterprise Developers
15 stars 29 forks source link

4.1 Back-end Development exercise, maven error #24

Closed martencassel closed 5 years ago

martencassel commented 5 years ago

I cannot manage to build the 4.1 api build with maven. I get a maven error in the 4.1 Back-end Development exercise. Would be a good idea to provide a gist for the ddev-labs/docker-compose/api/src/main/resources/application.yml file.

> docker-compose -f docker-compose-api.yml up --build

[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ddev 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.137 s
[INFO] Finished at: 2018-09-17T11:03:31Z
[INFO] Final Memory: 15M/128M
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase "COPY". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException
ERROR: Service 'apiserver' failed to build: The command '/bin/sh -c mvn -B -f pom.xml -s /usr/share/maven/ref/settings-docker.xml dependency:resolve COPY . .' returned a non-zero code: 1
version: "3.1"

services:
  database:
    build: 
      context: ./database
    image: ddev_db
    environment:
      POSTGRES_USER: gordonuser
      POSTGRES_DB: ddev
    ports:
      - "5432:5432" 
    networks:
      - back-tier
    secrets:
      - postgres_password

  apiserver:
    build:
      context: api
      dockerfile: Dockerfile.api
    image: ddev_api
    volumes:
      - ./api:/usr/src/ddev
    ports:
      - "8080:8080"
      - "5005:5005"
    networks:
      - back-tier
    secrets:
      - postgres_password

  watcher:
    build: 
      context: api
      dockerfile: Dockerfile.api
    volumes:
      - ./api:/usr/src/ddev
    command: mvn fizzed-watcher:run
    networks:
      - back-tier

secrets:
  postgres_password:
    file: ./devsecrets/postgres_password

networks:
  back-tier:
---
server:
  port: 8080
  contextPath: /
---
spring:
  profiles: local
datasource:
  ddev:
    url: jdbc:h2:~/test
    username: SA
    password:
    driverClassName: org.h2.Driver
    defaultSchema:
    maxPoolSize: 10
    hibernate:
      hbm2ddl.method: create-drop
      show_sql: true
      format_sql: true
      dialect: org.hibernate.dialect.H2Dialect
---
spring:
  profiles: postgres, default
  devtools:
    remote:
      secret: secretkey
    restart:
      enabled: true
    livereload:
      enabled: true
datasource:
  ddev:
    url: jdbc:postgresql://database:5432/ddev
    username: gordonuser
    password: gordonpass
    driverClassName: org.postgresql.Driver
    defaultSchema:
    maxConnections: 300
    initialConnections: 20
    maxAge: 30000
    testOnBorrow: true
    testWhileIdle:  true
    timeBetweenEvictionRunsMillis: 60000
    validationQuery: SELECT 1
    minPoolSize: 6
    maxPoolSize: 15
    hibernate:
      hbm2ddl.method: update
      show_sql: true
      format_sql: true
      dialect: org.hibernate.dialect.PostgreSQLDialect
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.3.RELEASE</version>
  </parent>

  <groupId>com.docker.ddev</groupId>
  <artifactId>ddev</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>ddev</name>

  <properties>
    <java.version>1.8</java.version>
    <h2.version>1.4.187</h2.version>
  </properties>

  <dependencies>
    <!-- Add typical dependencies for a web application -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
    </dependency>
    <!-- Add JPA support -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <!-- Add Hikari Connection Pooling support -->
    <dependency>
      <groupId>com.zaxxer</groupId>
      <artifactId>HikariCP</artifactId>
      </dependency>
    <!-- Add H2 database support [for running with local profile] -->
    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
    </dependency>
    <!-- Add PostgreSQL database support -->
    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
    </dependency>
    <!-- Postgres connection pooling -->
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-c3p0</artifactId>
      <version>5.2.10.Final</version>
    </dependency>
    <!--  Add Jdbc Template support -->    
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        </dependency>
    <dependency>
      <groupId>com.googlecode.json-simple</groupId>
      <artifactId>json-simple</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
      <!-- devtools support -->
      <dependency>
            <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.0</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin><!-- Create a jar with all dependencies, run commandline using java -jar NAME -->
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <excludeDevtools>true</excludeDevtools>
        </configuration>
      </plugin>
      <plugin>
    <groupId>com.fizzed</groupId>
    <artifactId>fizzed-watcher-maven-plugin</artifactId>
    <version>1.0.6</version>
    <configuration>
        <touchFile>target/classes/watcher.txt</touchFile>
        <watches>
            <watch>
                <directory>src/main/java/com/docker/ddev</directory>
            </watch>
        </watches>
        <goals>
            <goal>package</goal>
        </goals>
    </configuration>
</plugin>
    </plugins>
  </build>   
</project>

api/Dockerfile.api

FROM maven:3.5.0-jdk-8-alpine AS appserver
WORKDIR /usr/src/ddev
COPY pom.xml .
RUN mvn -B -f pom.xml -s /usr/share/maven/ref/settings-docker.xml dependency:resolve 
COPY . .
RUN mvn -B -s /usr/share/maven/ref/settings-docker.xml package -DskipTests 
EXPOSE 8080
CMD mvn spring-boot:run
martencassel commented 5 years ago

Copying from pdf to terminal doesnt work, the COPY command is not added to a newline.