Dockerfile can’t build app with Maven – No goals specified for this build

I’m developing a Spring Boot app with several data services, but I’m struggling to get it working as a containerized application. This is the project folder structure:

myapp/
├── src/
│   └── ...
├── docker-compose.yml
├── Dockerfile
├── init-mongo.js
└── pom.xml

And this is the Dockerfile content I came up with after reading tutorials and official documentation:

#
# Build stage
#
FROM maven:3.5-jdk-8 AS build
COPY init-mongo.js /docker-entrypoint-initdb.d/
COPY src /app/src/
COPY pom.xml /app/
RUN mvn -f /app/pom.xml clean package

#
# Package stage
#
FROM openjdk:8-alpine
COPY --from=build /app/target/*.jar /usr/app/app.jar
ENTRYPOINT ["java","-jar","/usr/app/app.jar"]

And this is my docker-compose.yml:

version: '3'
services:
  app-mongodb:
    container_name: app-mongodb
    image: mongo
    environment:
      MONGO_INITDB_DATABASE: appdb
      MONGO_INITDB_ROOT_USERNAME: mongodbusr
      MONGO_INITDB_ROOT_PASSWORD: mongodbpwd
    volumes:
      - mongodata:/usr/share/mongodb/data
    ports:
      - "27017:27017"
    hostname: app-mongodb

  app-mariadb:
    container_name: app-mariadb
    image: mariadb
    environment:
      MYSQL_DATABASE: appdb
      MYSQL_ROOT_PASSWORD: mariadbpwd
      MYSQL_ROOT_HOST: '%'
    ports:
      - "3306:3306"
    restart: always

  app-elasticsearch:
    container_name: app-elasticsearch
    image: docker.elastic.co/elasticsearch/elasticsearch:6.8.6
    volumes:
      - esdata:/usr/share/elasticsearch/data
    ports:
      - "9200:9200"
    hostname: app-elasticsearch

  app:
    build: .
    ports:
      - 8080:8080
    depends_on:
      - app-mariadb
      - app-mongodb
      - app-elasticsearch

volumes:
  mongodata:
  esdata:

Thing is it should work, but I keep getting Maven error whenever I run the docker-compose up command:

No goals have been specified for this build. 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, pr
ocess-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clea
n, pre-site, site, post-site, site-deploy. -> [Help 1]

What am I missing?

Source: Docker Questions