jkube icon indicating copy to clipboard operation
jkube copied to clipboard

Docker file optimization

Open fr35wo opened this issue 5 months ago • 5 comments

Component

quickstarts

Task description

Description

Set environment variable and don't use it Lack of clear working directory setting: Not setting a clear working directory can reduce readability.

https://github.com/eclipse-jkube/jkube/blob/522baa2100fc95ea3ca27a0a6e1a6d43861e7182/quickstarts/maven/plugin/app/Dockerfile#L17

https://github.com/eclipse-jkube/jkube/blob/522baa2100fc95ea3ca27a0a6e1a6d43861e7182/quickstarts/gradle/plugin/app/Dockerfile#L19-L20

I think it would be better to fix it like this

FROM quay.io/jkube/jkube-java:0.0.15

ENV JAVA_APP_DIR=/deployments

**Set working directory**
WORKDIR ${JAVA_APP_DIR}

COPY maven/build/libs/*.jar app.jar
COPY maven/build/classes/java/main/jkube-extra/ files/

EXPOSE 8080

CMD ["java", "-jar", "app.jar"]

Or, it might be a good idea to delete Set working directory.

Expected Behavior

Setting working directory: By using the WORKDIR command to set the working directory, subsequent commands are now clearer. Improved readability: The overall structure has been organized to improve readability.

fr35wo avatar Sep 07 '24 17:09 fr35wo