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

Merged
merged 28 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
684b151
Use multi-stage builds to unzip and copy jars
bradbown Sep 30, 2024
f209a29
Change base docker iamge
bradbown Sep 30, 2024
4924f16
Fix mkdir command
bradbown Oct 1, 2024
8e06945
Revert mkdir concat
bradbown Oct 1, 2024
c17fe39
Remove apt-get calls
bradbown Oct 1, 2024
ef7530a
Revert local COPY change
bradbown Oct 1, 2024
8a3b0b3
Use apk to install packages
bradbown Oct 1, 2024
34a103b
Revert to debian based image
bradbown Oct 1, 2024
19aaa14
Fix copy location
bradbown Oct 1, 2024
4fd1a97
Merge mkdir commands
bradbown Oct 1, 2024
5cf8920
Amended directories
bradbown Oct 4, 2024
e78d280
Remove libs based on platform
bradbown Oct 9, 2024
d947186
Use uname -m to get current architecture
bradbown Oct 9, 2024
646b934
Switch if statement to case statement to uname call
bradbown Oct 10, 2024
bf34d21
Fix zip copy
bradbown Oct 10, 2024
253ee73
Add WORKDIR to improve readability, move removal of darwin dir out of…
bradbown Oct 15, 2024
a7224f3
feat: change builder image to a more secure one
jonesho Nov 6, 2024
0459f97
feat: change builder and final image to eclipse-temurin 21-alpine
jonesho Nov 6, 2024
a9a187e
feat: removed unnecessary slash
jonesho Nov 19, 2024
753b80b
feat: update dockerfile to avoid hardcoded version for jar files
jonesho Nov 20, 2024
b50e6d2
feat: allow more flexible name matching for jar files
jonesho Nov 20, 2024
166f340
feat: use installDist in GHA job to avoid unzip
jonesho Nov 21, 2024
758e56f
feat: use installDist in GHA job to avoid unzip in transaction-exclus…
jonesho Nov 21, 2024
b720e10
feat: update manual image build for coordinator and tx-exclusion-api
jonesho Nov 22, 2024
eb11af2
feat: revert setting ssl and gssEncMode in tx-exclusion-api integrati…
jonesho Nov 22, 2024
c021d88
Merge branch 'main' into docker-coordinator-image-size-reduction
jonesho Dec 2, 2024
0179aa7
Merge branch 'main' into docker-coordinator-image-size-reduction
jonesho Dec 2, 2024
27cef5d
Merge branch 'main' into docker-coordinator-image-size-reduction
jonesho Dec 2, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/coordinator-build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
uses: gradle/actions/setup-gradle@v4
- name: Build dist
run: |
./gradlew coordinator:app:distZip --no-daemon
./gradlew coordinator:app:installDist --no-daemon
jpnovais marked this conversation as resolved.
Show resolved Hide resolved
- name: Login to Docker Hub
if: ${{ env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != '' }}
uses: docker/login-action@v3
Expand All @@ -98,7 +98,7 @@ jobs:
if: ${{ env.PUSH_IMAGE == 'false' }}
with:
context: .
build-contexts: zip=./coordinator/app/build/distributions/
build-contexts: libs=./coordinator/app/build/install/coordinator/lib
file: ./coordinator/Dockerfile
platforms: linux/amd64
load: true
Expand All @@ -120,7 +120,7 @@ jobs:
if: ${{ env.PUSH_IMAGE == 'true' || github.event_name == 'workflow_dispatch' }}
with:
context: .
build-contexts: zip=./coordinator/app/build/distributions/
build-contexts: libs=./coordinator/app/build/install/coordinator/lib
file: ./coordinator/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
uses: gradle/actions/setup-gradle@v4
- name: Build dist
run: |
./gradlew transaction-exclusion-api:app:distZip --no-daemon
./gradlew transaction-exclusion-api:app:installDist --no-daemon
- name: Login to Docker Hub
if: ${{ env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != '' }}
uses: docker/login-action@v3
Expand All @@ -98,7 +98,7 @@ jobs:
if: ${{ env.PUSH_IMAGE == 'false' }}
with:
context: .
build-contexts: zip=./transaction-exclusion-api/app/build/distributions/
build-contexts: libs=./transaction-exclusion-api/app/build/install/transaction-exclusion-api/lib
file: ./transaction-exclusion-api/Dockerfile
platforms: linux/amd64
load: true
Expand All @@ -120,7 +120,7 @@ jobs:
if: ${{ env.PUSH_IMAGE == 'true' || github.event_name == 'workflow_dispatch' }}
with:
context: .
build-contexts: zip=./transaction-exclusion-api/app/build/distributions/
build-contexts: libs=./transaction-exclusion-api/app/build/install/transaction-exclusion-api/lib
file: ./transaction-exclusion-api/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
Expand Down
44 changes: 30 additions & 14 deletions coordinator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,38 @@
FROM openjdk:22-ea-17-slim-bookworm
# BUILDER image
FROM eclipse-temurin:21-jdk-noble AS builder

jpnovais marked this conversation as resolved.
Show resolved Hide resolved
jonesho marked this conversation as resolved.
Show resolved Hide resolved
RUN apt-get update \
&& apt-get install curl -y \
&& apt-get install unzip -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /libs
COPY --from=libs ./** /libs
WORKDIR /libs

RUN mkdir -p unpacked-blob-compressor unpacked-blob-shnarf-calculator
RUN bcJar=$(set -- blob-compressor*.jar; echo $1) && \
bscJar=$(set -- blob-shnarf-calculator*.jar; echo $1) && \
cd unpacked-blob-compressor/ && jar -xf ../$bcJar && cd .. && \
cd unpacked-blob-shnarf-calculator/ && jar -xf ../$bscJar && cd .. && \
rm -rf unpacked-blob-compressor/darwin-** 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 && \
jar -cf $bcJar -C unpacked-blob-compressor . && \
jar -cf $bscJar -C unpacked-blob-shnarf-calculator .
RUN rm -rf unpacked-blob-compressor unpacked-blob-shnarf-calculator

# FINAL image
FROM eclipse-temurin:21-jre-noble

jpnovais marked this conversation as resolved.
Show resolved Hide resolved
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 mkdir -p logs /tmp/prover/request /tmp/prover/response

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/** libs/

# Build-time metadata as defined at http://label-schema.org
ARG BUILD_DATE
Expand All @@ -29,5 +47,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/
17 changes: 2 additions & 15 deletions transaction-exclusion-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
# BUILDER image
FROM eclipse-temurin:21-jre-alpine AS builder
WORKDIR /opt/consensys/linea/transaction-exclusion-api

RUN apk add --no-cache unzip

# copy application
COPY --from=zip ./transaction-exclusion-api.zip libs/
RUN unzip libs/transaction-exclusion-api.zip -d libs/ \
&& mv libs/transaction-exclusion-api/lib/** libs/ \
&& rm -R libs/transaction-exclusion-api/

# FINAL image
FROM eclipse-temurin:21-jre-alpine
WORKDIR /opt/consensys/linea/transaction-exclusion-api/

RUN mkdir -p /opt/consensys/linea/transaction-exclusion-api/logs/
RUN mkdir -p logs

COPY --from=builder /opt/consensys/linea/transaction-exclusion-api/libs libs/
COPY --from=libs ./** libs/

# Build-time metadata as defined at http://label-schema.org
ARG BUILD_DATE
Expand Down
Loading