I use Heroku Java Docker Image and docker-compose to run the local Java-based dropwizard web service.
When I run the command docker-compose build webto create the code, it loads several dependencies each time. Thus, the processing time of the assembly process has increased.
My project docker file is just one line: FROM heroku/java
Here is the build log:
[INFO] ------------------------------------------------------------------------
[INFO] Building generator-app-server 0.0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https:
Downloaded: https:
Downloading: https:
Downloaded: https:
Downloading: https:
Downloaded: https:
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ generator-app-server ---
Downloading: https:
Downloaded: https:
Downloading: https:
Downloaded: https:
Downloading: https:
Downloaded: https:
Downloading: https:
Downloaded: https:
[INFO] Deleting /app/user/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ generator-app-server ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 7 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ generator-app-server ---
Downloading: https:
Downloaded: https:
Downloading: https:
Downloaded: https:
docker-compose builddoes not use cached dependencies for the above libraries. How to force cached dependencies?
Googled a lot, but no luck. Share if anyone collided and fixed.
Update:
Dockerfile
FROM heroku/java
docker-compose.yml
web:
build: .
command: 'bash -c ''java $JAVA_OPTS -jar target/generator-app-server-0.0.2-SNAPSHOT.jar db migrate config.yml && java $JAVA_OPTS -Ddw.server.connector.port=$PORT -jar target/generator-app-server-0.0.2-SNAPSHOT.jar server config.yml'''
working_dir: /app/user
environment:
PORT: 8080
DATABASE_URL: 'postgres://postgres:@herokuPostgresql:5432/postgres'
ports:
- '8080:8080'
links:
- herokuPostgresql
shell:
build: .
command: bash
working_dir: /app/user
environment:
PORT: 8080
DATABASE_URL: 'postgres://postgres:@herokuPostgresql:5432/postgres'
ports:
- '8080:8080'
links:
- herokuPostgresql
volumes:
- '.:/app/user'
herokuPostgresql:
image: postgres