3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

DockerでGradle Projectのbuildをする

Posted at

方法

gradleがインストールされているDocker containerに、gradleのprojectをvolumeで見せてbuildする。

$ cd /path/to/gradle/project

$ docker run \
  -v $PWD:/app \
  -w /app \
  -u $UID:$GID \
  takitake/gradle-alpine \
  gradle wrapper && ./gradlew clean build

解説

-v $PWD:/app

.だと、不正なファイルパスだと怒られてしまうので、絶対パスで指定する。

-w /app

マウントしたディレクトリへ移動。

-u $UID:$GID

現在のユーザ権限でjar/warを作らせる。

takitake/gradle-alpine

Alpineの勉強がてら、Docker Image作ったので使ってやってください。
https://hub.docker.com/r/takitake/gradle-alpine/

ちなみに、実行方法

$ docker run \
  -v $PWD:/app \
  -w /app \
  -u $UID:$GID \
  -p 8080:8080 \
  java:8-jre-alpine \
  java -jar build/libs/xxx.jar

Officialなjava imageがあるので、それを使うのが手っ取り早いし軽いです。

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?