Skip to content

Commit

Permalink
Dockerize maven install (#133)
Browse files Browse the repository at this point in the history
* Refactor Dockerfiles to use multi-stage builds.
Simplified builds by introducing Maven-based multi-stage builds, consolidating dependencies, and reducing image sizes. Updated entry points to ensure runtime efficiency and maintainability. Transitioned from `ADD` to `COPY` for better clarity and consistency.
  • Loading branch information
Gcolon021 authored Jan 13, 2025
1 parent 6239b75 commit b52d06f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 21 deletions.
50 changes: 31 additions & 19 deletions docker/pic-sure-hpds-etl/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
FROM maven:3.9.4-amazoncorretto-21 AS build

RUN yum update -y && yum install -y git && yum clean all

WORKDIR /app

COPY .m2 /root/.m2

COPY . .

RUN mvn clean install -DskipTests

FROM eclipse-temurin:21-alpine

RUN apk add --no-cache --purge -uU bash && rm -rf /var/cache/apk/* /tmp/*

RUN apk add --no-cache --purge -uU curl wget unzip gnupg openssl

ADD create_key.sh .
ADD SQLLoader-jar-with-dependencies.jar .
ADD CSVLoader-jar-with-dependencies.jar .
ADD CSVLoaderNewSearch-jar-with-dependencies.jar .
ADD CSVDumper-jar-with-dependencies.jar .
ADD VCFLocalLoader-jar-with-dependencies.jar .
ADD VariantMetadataLoader-jar-with-dependencies.jar .
ADD UnifiedVCFLocalLoader-jar-with-dependencies.jar .
ADD MultialleleCounter-jar-with-dependencies.jar .
ADD RekeyDataset-jar-with-dependencies.jar .
ADD RemoveConceptFromMetadata-jar-with-dependencies.jar .
ADD HideAnnotationCategoryValue-jar-with-dependencies.jar .
ADD SequentialLoader-jar-with-dependencies.jar .

ENTRYPOINT java $JAVA_OPTS -Xmx${HEAPSIZE:-2048}m -jar ${LOADER_NAME:-CSVLoader}-jar-with-dependencies.jar
RUN apk add --no-cache --purge -uU bash curl wget unzip gnupg openssl && \
rm -rf /var/cache/apk/* /tmp/*

WORKDIR /app
COPY --from=build /app/docker/pic-sure-hpds-etl/SQLLoader-jar-with-dependencies.jar .
COPY --from=build /app/docker/pic-sure-hpds-etl/CSVLoader-jar-with-dependencies.jar .
COPY --from=build /app/docker/pic-sure-hpds-etl/CSVLoaderNewSearch-jar-with-dependencies.jar .
COPY --from=build /app/docker/pic-sure-hpds-etl/CSVDumper-jar-with-dependencies.jar .
COPY --from=build /app/docker/pic-sure-hpds-etl/VCFLocalLoader-jar-with-dependencies.jar .
COPY --from=build /app/docker/pic-sure-hpds-etl/VariantMetadataLoader-jar-with-dependencies.jar .
COPY --from=build /app/docker/pic-sure-hpds-etl/UnifiedVCFLocalLoader-jar-with-dependencies.jar .
COPY --from=build /app/docker/pic-sure-hpds-etl/MultialleleCounter-jar-with-dependencies.jar .
COPY --from=build /app/docker/pic-sure-hpds-etl/RekeyDataset-jar-with-dependencies.jar .
COPY --from=build /app/docker/pic-sure-hpds-etl/RemoveConceptFromMetadata-jar-with-dependencies.jar .
COPY --from=build /app/docker/pic-sure-hpds-etl/HideAnnotationCategoryValue-jar-with-dependencies.jar .
COPY --from=build /app/docker/pic-sure-hpds-etl/SequentialLoader-jar-with-dependencies.jar .
COPY --from=build /app/docker/pic-sure-hpds-etl/create_key.sh .

ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -Xmx${HEAPSIZE:-2048}m -jar ${LOADER_NAME:-CSVLoader}-jar-with-dependencies.jar"]
17 changes: 15 additions & 2 deletions docker/pic-sure-hpds/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
FROM maven:3.9.4-amazoncorretto-21 AS build

RUN yum update -y && yum install -y git && yum clean all

WORKDIR /app

COPY .m2 /root/.m2

COPY . .

RUN mvn clean install -DskipTests

FROM amazoncorretto:21.0.1-alpine3.18

# Copy jar and access token from maven build
ADD service-3.0.0-SNAPSHOT.jar /service.jar
WORKDIR /app

COPY --from=build /app/service/target/service-*-SNAPSHOT.jar /service.jar

ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} -jar /service.jar"]

0 comments on commit b52d06f

Please sign in to comment.