LoginSignup
4
5

More than 3 years have passed since last update.

GitHub Package RegistryにDocker Imageを公開する

Posted at

GitHub Package Registryに、Dockerイメージを作成する。
今回はJibでJavaアプリケーションのイメージを作成し、プッシュすることを目標にする。

公式
GitHub Package RegistryにGradleでJARを公開する

Gradleの設定

build.gradle
plugins {
    id 'com.google.cloud.tools.jib' version '1.5.1'
}

jib {
    to {
        image = "docker.pkg.github.com/minebreaker/abukuma/abukuma-example:0.0.0.2-EXPLORING_GITHUB_REGISTRY"
        auth {
            username = project.hasProperty("GITHUB_USER") ? GITHUB_USER : ''
            password = project.hasProperty("GITHUB_TOKEN") ? GITHUB_TOKEN : ''
        }
    }
}

注意すべきなのは、ユーザー名やリポジトリが大文字であっても、小文字に変換して記述しなければいけないこと。

早速jibタスクでビルド&公開。

* What went wrong:
Execution failed for task ':abukuma-example:jib'.
> com.google.cloud.tools.jib.plugins.common.BuildStepsExecutionException: Tried to check BLOB exists for docker.pkg.github.com/minebreaker/abukuma/abukuma-example with digest sha256:e8d8785a314f385d3675a017f4e2df1707c528c06e7a7989663fdab4900bd8ff but failed because: Did not receive Content-Length header | If this is a bug, please file an issue at https://github.com/GoogleContainerTools/jib/issues/new

これは怪しい。。。
Content-Lengthが見えないという事は大抵、リクエストに応答していない場合が多いように思う。

ビルド

仕方がないので、jibDockerBuildでイメージだけを作成。

Built image to Docker daemon as docker.pkg.github.com/minebreaker/abukuma/abukuma-example:0.0.0.2-EXPLORING_GITHUB_REGISTRY
Executing tasks:
[==============================] 100.0% complete

> Task :abukuma-example:jibDockerBuild

BUILD SUCCESSFUL in 10s

ドキュメントに従えば、問題なくプッシュできた。

docker login docker.pkg.github.com -u minebreaker -p [[TOKEN]]
docker push docker.pkg.github.com/minebreaker/abukuma/abukuma-example:0.0.0.2-EXPLORING_GITHUB_REGISTRY

プル。

docker pull docker.pkg.github.com/minebreaker/abukuma/abukuma-example:0.0.0.2-exploring_github_registry

まとめ

Jibで完結させたいが...。

4
5
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
4
5