私はHeroku Java Docker Imageとdocker-composeを使って、dropwizard JavaベースのWebサービスをローカルで実行しています。docker-composeビルドの度に、いくつかの依存関係がダウンロードされます
コードをビルドするコマンドdocker-compose build web
を実行すると、毎回依存関係のダウンロードが少なくなります。したがって、プロセスの処理時間が長くなります。
マイプロジェクトのドッキングウィンドウのファイルは、単一の行です:
[INFO] ------------------------------------------------------------------------
[INFO] Building generator-app-server 0.0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom (4 KB at 0.7 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/22/maven-plugins-22.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/22/maven-plugins-22.pom (13 KB at 9.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.jar (25 KB at 14.7 KB/sec)
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ generator-app-server ---
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0/plexus-utils-3.0.pom
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0/plexus-utils-3.0.pom (4 KB at 5.4 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/sonatype/spice/spice-parent/16/spice-parent-16.pom
Downloaded: https://repo.maven.apache.org/maven2/org/sonatype/spice/spice-parent/16/spice-parent-16.pom (9 KB at 4.9 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/sonatype/forge/forge-parent/5/forge-parent-5.pom
Downloaded: https://repo.maven.apache.org/maven2/org/sonatype/forge/forge-parent/5/forge-parent-5.pom (9 KB at 5.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0/plexus-utils-3.0.jar
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0/plexus-utils-3.0.jar (221 KB at 20.0 KB/sec)
[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://repo.maven.apache.org/maven2/org/mapstruct/mapstruct-processor/1.1.0.Final/mapstruct-processor-1.1.0.Final.jar
Downloaded: https://repo.maven.apache.org/maven2/org/mapstruct/mapstruct-processor/1.1.0.Final/mapstruct-processor-1.1.0.Final.jar (1502 KB at 24.5 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/mapstruct/mapstruct-processor/1.1.0.Final/mapstruct-processor-1.1.0.Final.pom
Downloaded: https://repo.maven.apache.org/maven2/org/mapstruct/mapstruct-processor/1.1.0.Final/mapstruct-processor-1.1.0.Final.pom (12 KB at 4.9 KB/sec)
docker-compose build
上記のlibsのためにキャッシュされた依存関係を使用していない:FROM heroku/java
ここでは、ログを構築しています。キャッシュされた依存関係を強制的に使用する方法
グーグルではありますが運がありません。誰かが直面していて固定していれば共有してください。
更新:
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
質問は何ですか? –
既にビルドしたイメージを使用する場合は、** build **の代わりに** up **コマンドを使用できます。ただし、DockerfileにADDまたはCOPYがあり、ファイルを変更した場合は、イメージを再構築するために** - build **フラグを追加する必要があります。 –
@AndyShinn更新された質問 –