Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade docker base image #49

Merged
merged 1 commit into from
Jul 22, 2022
Merged

Upgrade docker base image #49

merged 1 commit into from
Jul 22, 2022

Conversation

kuroponzu
Copy link
Contributor

@kuroponzu kuroponzu commented Jul 20, 2022

summary

Upgrade the docker base image.

Why change it?

Bump dependencies

Bump dependencies and use java 17.
#48

Base image is deprecated

openjdk_8 is now deprecated.
https://hub.docker.com/_/openjdk/

This image is officially deprecated and all users are recommended to find and use suitable replacements ASAP. Some examples of other Official Image alternatives (listed in alphabetical order with no intentional or implied preference):
amazoncorretto
eclipse-temurin
ibm-semeru-runtimes
ibmjava
sapmachine
See docker-library/openjdk#505 for more information.
The only tags which will continue to receive updates beyond July 2022 will be Early Access builds (which are sourced from jdk.java.net), as those are not published/supported by any of the above projects.

details

I choise the images of eclipse-temurin, because it not depends on identification platform.
ex) amazoncorretto is for aws-service

However, I don't have any strong opinion about it, so if you have any images to recommend, let me know.

ref) https://future-architect.github.io/articles/20211220a/

@@ -22,5 +22,5 @@ RUN useradd --create-home app \

USER app

ENTRYPOINT ["/usr/bin/java"]
ENTRYPOINT ["/opt/java/openjdk/bin/java"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❯ docker run -it eclipse-temurin:17 /bin/bash
root@d2eec3087d0c:/# which java
/opt/java/openjdk/bin/java

@kuroponzu kuroponzu changed the title To use java 17 Update docker base image Jul 20, 2022
@kuroponzu kuroponzu changed the title Update docker base image Upgradedocker base image Jul 20, 2022
@kuroponzu kuroponzu changed the title Upgradedocker base image Upgrade docker base image Jul 20, 2022
@kuroponzu kuroponzu self-assigned this Jul 20, 2022
@kuroponzu kuroponzu marked this pull request as ready for review July 20, 2022 06:25
@kuroponzu kuroponzu requested a review from a team July 20, 2022 08:24
Copy link

@katojio katojio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upgrade 対応ありがとうございます!
変更内容自体は問題なさそうに見えています 🙆‍♂️

ちなみに動作確認としては何が確認できればOKと言えそうですかね...?

@kuroponzu
Copy link
Contributor Author

レビューありがとうございます!

ちなみに動作確認としては何が確認できればOKと言えそうですかね...?

docker build出来ると良さそうかなと思います。が、少し手間がかかります😖

  • ローカルの端末に以下のミドルウェアを導入する。
    • openjdk@17
    • homebrewから取得できます。
  • ./gradlew stage を実行する。
    • bin/plantuml-service.jar が作成されることを確認する。

dockerfileを以下のように書き換える

# https://hub.docker.com/_/eclipse-temurin?tab=description&page=2&name=17
FROM eclipse-temurin:17

ARG PLANTUML_SERVICE_VERSION
ARG PLANTUML_SERVICE_JAR_URL="https://github.com/bitjourney/plantuml-service/releases/download/v${PLANTUML_SERVICE_VERSION}/plantuml-service.jar"
ARG PLANTUML_SERVICE_BIN_DIR="/home/app/plantuml-service/bin"
ARG PLANTUML_SERVICE_PATH="${PLANTUML_SERVICE_BIN_DIR}/plantuml-service.jar"

USER root

COPY bin/plantuml-service.jar /home/app/plantuml-service/bin/

RUN useradd --create-home app \
  && apt-get update -qq \
  && apt-get upgrade -y \
  && apt-get install -y graphviz fonts-takao curl \
  && apt-get clean \
  && rm -rf /var/lib/apt/lists/* \
  && mkdir -p ${PLANTUML_SERVICE_BIN_DIR} \
  && chown -R app ${PLANTUML_SERVICE_BIN_DIR}

USER app

ENTRYPOINT ["/opt/java/openjdk/bin/java"]
CMD ["-jar", "/home/app/plantuml-service/bin/plantuml-service.jar"]
  • docker build . を実効し成功することを確認する。

感じですかね 👀

@katojio
Copy link

katojio commented Jul 22, 2022

手順ありがとうございます!

./gradlew stage を実行する。

ここでエラーが出たので、確認中です 🙏

> Task :compileKotlin FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileKotlin'.
> Failed to query the value of task ':compileKotlin' property 'compilerRunner$kotlin_gradle_plugin'.
   > Kotlin could not find the required JDK tools in the Java installation. Make sure Kotlin compilation is running on a JDK, not JRE.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.4.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 43s
1 actionable task: 1 executed

@katojio
Copy link

katojio commented Jul 22, 2022

--infoを付けて実行。

> Task :compileKotlin FAILED
Caching disabled for task ':compileKotlin' because:
  Build cache is disabled
Task ':compileKotlin' is not up-to-date because:
  Task has failed previously.
The input changes require a full rebuild for incremental task ':compileKotlin'.
file or directory '/Users/kodai/plantuml-service/src/main/java', not found
:compileKotlin (Thread[Execution worker for ':',5,main]) completed. Took 0.147 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileKotlin'.
> Failed to query the value of task ':compileKotlin' property 'compilerRunner$kotlin_gradle_plugin'.
   > Kotlin could not find the required JDK tools in the Java installation. Make sure Kotlin compilation is running on a JDK, not JRE.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.4.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1s
1 actionable task: 1 executed
Watched directory hierarchies: [/Users/kodai/plantuml-service]

file or directory '/Users/kodai/plantuml-service/src/main/java', not found

確かに /src/main 以下には kotlin というフォルダしか無いので、java ってフォルダは無いなとなっている

@kuroponzu
Copy link
Contributor Author

手元の環境でwhich javaと入力して結果を張ってもらってもいいですか?

@katojio
Copy link

katojio commented Jul 22, 2022

Kotlin could not find the required JDK tools in the Java installation. Make sure Kotlin compilation is running on a JDK, not JRE

このエラーメッセージでググってみました。
https://zenn.dev/tsuruo/scraps/1e923860095e6e を参考にコマンドを叩いてみましたが、jdk は表示されるのでインストールはできていそう。

> /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
    1.8.333.02 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
    1.8.0_292 (x86_64) "AdoptOpenJDK" - "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

@katojio
Copy link

katojio commented Jul 22, 2022

@kuroponzu こちらでした〜!

> which java
/usr/bin/java

@katojio
Copy link

katojio commented Jul 22, 2022

path を通したら成功するようになった 👏

> which java
/opt/homebrew/opt/openjdk@17/bin/java

Copy link

@katojio katojio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker build . が成功することが確認できました!LGTM!

@kuroponzu kuroponzu merged commit 8853727 into master Jul 22, 2022
@kuroponzu kuroponzu deleted the upgrade_docker_base_image branch July 22, 2022 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants