@@ -8,68 +8,66 @@ RUN apk update && apk --no-cache add \
88 libsodium-dev
99
1010WORKDIR /usr/app
11-
1211COPY . .
1312RUN --mount=type=cache,target=/usr/local/cargo/registry \
1413 --mount=type=cache,target=/app/target \
1514 cargo install --root /usr/app --path . --debug --locked
1615
17- # Setting up build directories
16+
17+ # ---------- Final stage ----------
1818FROM --platform=${BUILDPLATFORM} cgr.dev/chainguard/wolfi-base
1919
2020WORKDIR /app
21- # COPY --chown=nonroot:nonroot ./config /app/config
21+
22+ # Binary + libs
2223COPY --from=base --chown=nonroot:nonroot /usr/app/bin/openzeppelin-relayer /app/openzeppelin-relayer
2324COPY --from=base /usr/lib/libssl.so.3 /usr/lib/libssl.so.3
2425COPY --from=base /usr/lib/libcrypto.so.3 /usr/lib/libcrypto.so.3
2526
26- # Install plugin dependencies
27- ARG TARGETARCH
28- ARG NODE_VERSION=20.19
27+ # Bring source tree from base so we can optionally bake files
28+ COPY --from=base /usr/app /tmp/src
2929
30- # Install Node.js
30+ # Install Node + tooling (root needed here)
3131USER root
32- RUN apk add --no-cache nodejs=~${NODE_VERSION} npm
33- ENV PATH="/usr/local/bin:$PATH"
34-
35- RUN npm install -g pnpm ts-node typescript
36-
37- # removes apk and unneeded wolfi-base tools.
38- RUN apk del wolfi-base apk-tools
39-
40- # Copy plugins folder and install dependencies
41- COPY --chown=nonroot:nonroot ./plugins /app/plugins
42-
43- USER nonroot
44- WORKDIR /app/plugins
45- RUN pnpm install --frozen-lockfile
32+ ARG NODE_VERSION=20.19
33+ RUN apk add --no-cache nodejs=~${NODE_VERSION} npm && \
34+ npm install -g pnpm ts-node typescript
4635
36+ # Optional baking from /tmp/src into /app BEFORE installing deps
4737ARG BAKE_CONFIGS=false
48-
4938RUN set -eux; \
5039 if [ "${BAKE_CONFIGS}" = "true" ]; then \
51- if [ -d /usr/app /examples/launchtube-plugin-example/config ]; then \
40+ if [ -d /tmp/src /examples/launchtube-plugin-example/config ]; then \
5241 mkdir -p /app/config; \
53- cp -a /usr/app /examples/launchtube-plugin-example/config/. /app/config/; \
42+ cp -a /tmp/src /examples/launchtube-plugin-example/config/. /app/config/; \
5443 fi; \
55- if [ -d /usr/app /config/networks ]; then \
44+ if [ -d /tmp/src /config/networks ]; then \
5645 mkdir -p /app/config/networks; \
57- cp -a /usr/app /config/networks/. /app/config/networks/; \
46+ cp -a /tmp/src /config/networks/. /app/config/networks/; \
5847 fi; \
59- if [ -d /usr/app /examples/launchtube-plugin-example/launchtube ]; then \
48+ if [ -d /tmp/src /examples/launchtube-plugin-example/launchtube ]; then \
6049 mkdir -p /app/plugins/launchtube; \
61- cp -a /usr/app /examples/launchtube-plugin-example/launchtube/. /app/plugins/launchtube/; \
50+ cp -a /tmp/src /examples/launchtube-plugin-example/launchtube/. /app/plugins/launchtube/; \
6251 fi; \
52+ chown -R nonroot:nonroot /app/config /app/plugins || true; \
6353 fi
6454
55+ COPY --chown=nonroot:nonroot ./plugins /app/plugins
6556
66- # Return to app root
67- WORKDIR /app
57+ # Install plugin deps AFTER bake so launchtube deps are included
58+ USER nonroot
59+ WORKDIR /app/plugins
60+ RUN pnpm install --frozen-lockfile
61+
62+ # Clean up build-only sources
63+ USER root
64+ RUN rm -rf /tmp/src && apk del apk-tools wolfi-base || true
65+ USER nonroot
6866
67+ # Back to app root
68+ WORKDIR /app
6969ENV APP_PORT=8080
7070ENV METRICS_PORT=8081
71-
7271EXPOSE ${APP_PORT}/tcp ${METRICS_PORT}/tcp
7372
74- # starting up
7573ENTRYPOINT ["/app/openzeppelin-relayer"]
0 commit comments