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

Use multi-stage builds to unzip and copy jars #118

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 39 additions & 14 deletions coordinator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,47 @@
FROM openjdk:22-ea-17-slim-bookworm
FROM openjdk:21-jdk-slim AS builder

RUN apt-get update \
&& apt-get install curl -y \
&& apt-get install unzip -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install unzip -y

RUN mkdir -p /src /libs

COPY --from=zip ./coordinator.zip /src

RUN unzip /src/coordinator.zip -d /libs

WORKDIR /libs/coordinator/lib/
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest to add the below line here to avoid the repeated prefix in paths:

WORKDIR /libs/coordinator/lib/


RUN mkdir -p unpacked-blob-compressor unpacked-blob-shnarf-calculator
RUN cd unpacked-blob-compressor/ && jar -xf ../blob-compressor-0.0.4.jar
RUN cd unpacked-blob-shnarf-calculator/ && jar -xf ../blob-shnarf-calculator-0.0.4.jar

RUN rm -rf unpacked-blob-compressor/darwin-** && \
rm -rf unpacked-blob-shnarf-calculator/darwin-** && \
case $(uname -m) in \
x86_64) \
rm -rf unpacked-blob-compressor/linux-aarch64/; \
rm -rf unpacked-blob-shnarf-calculator/linux-aarch64/; \
;; \
aarch64) \
rm -rf unpacked-blob-compressor/linux-x86-64/; \
rm -rf unpacked-blob-shnarf-calculator/linux-x86-64/; \
;; \
esac

RUN jar -cf blob-compressor-0.0.4.jar -C unpacked-blob-compressor . && \
jar -cf blob-shnarf-calculator-0.0.4.jar -C unpacked-blob-shnarf-calculator . && \
rm -rf unpacked-blob-compressor && rm -rf unpacked-blob-shnarf-calculator

FROM openjdk:21-jdk-slim

WORKDIR /opt/consensys/linea/coordinator

# copy application
COPY --from=zip ./coordinator.zip /opt/consensys/linea/coordinator/libs/
RUN unzip libs/coordinator.zip -d libs/ && mv libs/coordinator/lib/** libs/ && rm -R libs/coordinator/
RUN apt-get update \
&& apt-get install curl -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /libs/ /logs /tmp/prover/request /tmp/prover/response
Copy link
Contributor

Choose a reason for hiding this comment

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

I dun think we even need these apt-get related commands here, right?


RUN mkdir -p /opt/consensys/linea/coordinator/logs
RUN mkdir -p /opt/consensys/linea/coordinator/tmp/prover/request
RUN mkdir -p /opt/consensys/linea/coordinator/tmp/prover/response
COPY --from=builder /libs/coordinator/lib/** libs/

# Build-time metadata as defined at http://label-schema.org
ARG BUILD_DATE
Expand All @@ -29,5 +56,3 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.vendor="ConsenSys" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0"

WORKDIR /opt/consensys/linea/coordinator/
Loading