Skip to content

Commit

Permalink
Reduce size of cli docker image by removing tar (#214)
Browse files Browse the repository at this point in the history
* Reduce size of cli docker image by removing tar

fixes: #213

Have the Gradle build unpack the distribution tar archive. This means there is no need to install tar or to have the tar file in the Docker image.

* oops - still need to copy the expanded archive in

* Switch to a smaller base image

fixes: #213
  • Loading branch information
big-andy-coates authored Oct 4, 2023
1 parent 5d21aef commit 95f2091
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
FROM amazoncorretto:20@sha256:ac32b3e93f843470c7f55b7d694df016def3d02d55de83e2f43d432a8884b3a4
FROM eclipse-temurin:11-jre-focal@sha256:4c1ab549795f20b661bfaaa22716e5e10a8eae66a534e668a1e028683c810efa

ARG APP_NAME
ARG APP_VERSION
ENV VERSION=$APP_VERSION

LABEL org.opencontainers.image.source=https://github.com/specmesh/specmesh-build/tree/main/cli

RUN yum update -y
RUN yum install -y tar lsof

RUN mkdir -p /opt/specmesh

COPY bin /bin
COPY log4j /log

RUN chmod +x /bin/*.sh

COPY ${APP_NAME}-${APP_VERSION}.tar /opt/specmesh
COPY ${APP_NAME}-${APP_VERSION} /opt/specmesh/${APP_NAME}-${APP_VERSION}
WORKDIR /opt/specmesh

RUN tar xf ${APP_NAME}-${APP_VERSION}.tar
RUN ln -s ${APP_NAME}-${APP_VERSION} service



ENTRYPOINT ["/bin/wrapper.sh"]
#No CMD instruction is provided, allowing you to pass any number of arguments at runtime.
2 changes: 1 addition & 1 deletion cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ tasks.register<Copy>("prepareDocker") {

from(
layout.projectDirectory.file("Dockerfile"),
layout.buildDirectory.file("distributions/${project.name}-${project.version}.tar"),
tarTree(layout.buildDirectory.file("distributions/${project.name}-${project.version}.tar")),
layout.projectDirectory.dir("include"),
)

Expand Down

0 comments on commit 95f2091

Please sign in to comment.