Skip to content

Commit

Permalink
refactor: one image
Browse files Browse the repository at this point in the history
  • Loading branch information
0xaatif committed Jul 4, 2024
1 parent e365faf commit d96a5f1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 37 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
uses: actions/checkout@v4

- run: |
docker build --progress=plain --build-arg=PROFILE=dev --build-arg=ENTRYPOINT=leader --tag scratch .
docker run --rm scratch --help
docker build --progress=plain --build-arg=PROFILE=dev --build-arg=ENTRYPOINT=worker --tag scratch .
docker run --rm scratch --help
docker build --progress=plain --build-arg=PROFILE=dev --tag scratch .
docker run --rm --init --entrypoint leader scratch --help
docker run --rm --init --entrypoint worker scratch --help
docker run --rm --init --entrypoint rpc scratch --help
docker run --rm --init --entrypoint verifier scratch --help
14 changes: 1 addition & 13 deletions .github/workflows/docker_build_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ jobs:
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Push to GitHub Container Registry - Leader
- name: Push to GitHub Container Registry
uses: docker/build-push-action@v3
with:
build-args: ["ENTRYPOINT=leader"]
push: true
# platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta_leader.outputs.tags }}
Expand All @@ -68,14 +67,3 @@ jobs:
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Push to GitHub Container Registry - Worker
uses: docker/build-push-action@v3
with:
build-args: ["ENTRYPOINT=worker"]
push: true
# platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta_worker.outputs.tags }}
labels: ${{ steps.meta_worker.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
22 changes: 3 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This is loosely based on `docker init`'s rust template.
# For a completely clean build, run something like this:
# ```
# docker build --build-arg=PROFILE=dev --build-arg=ENTRYPOINT=leader --no-cache
# docker build --build-arg=PROFILE=dev --no-cache
# ```

#############
Expand Down Expand Up @@ -80,26 +80,10 @@ FROM debian:bullseye-slim AS final
RUN apt-get update && apt-get install -y \
ca-certificates \
libjemalloc2 \
libssl-dev \
tini \
&& rm -rf /var/lib/apt/lists/*

COPY --from=build /output/* /usr/local/bin/
RUN <<EOF
set -eux
: smoke test executables
find /usr/local/bin -type f -executable -print0 \
| xargs --null --replace --verbose tini -- {} --help
EOF

# can't refer to docker args in an ENTRYPOINT directive, so go through a symlink
ARG ENTRYPOINT
RUN ln --symbolic --verbose -- "$(which ${ENTRYPOINT})" /entrypoint
ENTRYPOINT [ "tini", "--", "/entrypoint" ]

# TODO(0xaatif): https://github.com/0xPolygonZero/zk_evm/issues/356
# this is bad practice
COPY .env /
# this keeps this build target agnostic to the build profile
COPY --from=build ["/output/rpc", "/output/leader", "/output/worker", "/output/verifier", "/usr/local/bin/"]

# Create a non-privileged user that the app will run under.
# See https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
Expand Down

0 comments on commit d96a5f1

Please sign in to comment.