@@ -59,24 +59,52 @@ WORKDIR /usr/src/app/packages/erc4337-contracts
5959RUN forge soldeer install
6060RUN forge build
6161
62- # Build ERC-4337 related packages
62+ # Build ERC-4337 related packages (following CI build order)
6363WORKDIR /usr/src/app
6464
65- # Build auth-server-api
66- RUN pnpm nx build auth-server-api
65+ # Build in correct dependency order: web-sdk -> sdk-4337 -> auth-server-api
66+ RUN pnpm nx build web-sdk
67+ RUN pnpm nx build sdk-4337 || (echo "===SDK-4337 Build Failed, trying direct build===" && cd packages/sdk-4337 && pnpm build)
68+ RUN pnpm nx build auth-server-api || (echo "===Auth-Server-API Build Failed, trying direct build===" && cd packages/auth-server-api && pnpm build)
6769
6870# Deploy only production dependencies for auth-server-api
6971RUN pnpm deploy --filter=auth-server-api --prod /prod/auth-server-api
7072
7173# Stage 3: Production runtime
72- # Using distroless for minimal attack surface
73- FROM gcr.io/distroless/nodejs22-debian12:nonroot AS production
74+ FROM node:22-slim AS production
75+
76+ # Install curl for healthcheck
77+ RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
7478
7579# Copy the deployed auth-server-api with its dependencies
76- COPY --from=builder --chown=nonroot:nonroot /prod/auth-server-api /prod/auth-server-api
80+ COPY --from=builder /prod/auth-server-api /prod/auth-server-api
7781
7882# Copy the built dist folder
79- COPY --from=builder --chown=nonroot:nonroot /usr/src/app/packages/auth-server-api/dist /prod/auth-server-api/dist
83+ COPY --from=builder /usr/src/app/packages/auth-server-api/dist /prod/auth-server-api/dist
84+
85+ # Copy sdk-4337 built files to node_modules
86+ COPY --from=builder /usr/src/app/packages/sdk-4337/dist /prod/auth-server-api/node_modules/zksync-sso-4337/dist
87+
88+ # Copy web-sdk built files and WASM packages to .pnpm directory structure
89+ RUN mkdir -p $(find /prod/auth-server-api/node_modules/.pnpm -type d -name "zksync-sso-web-sdk" 2>/dev/null | head -1)
90+ COPY --from=builder /usr/src/app/packages/sdk-platforms/web/pkg-bundler /tmp/pkg-bundler
91+ COPY --from=builder /usr/src/app/packages/sdk-platforms/web/pkg-node /tmp/pkg-node
92+ COPY --from=builder /usr/src/app/packages/sdk-platforms/web/dist /tmp/web-dist
93+ RUN PNPM_WEB_SDK=$(find /prod/auth-server-api/node_modules/.pnpm -type d -name "zksync-sso-web-sdk" 2>/dev/null | head -1) && \
94+ if [ -n "$PNPM_WEB_SDK" ]; then \
95+ cp -r /tmp/pkg-bundler "$PNPM_WEB_SDK/" && \
96+ cp -r /tmp/pkg-node "$PNPM_WEB_SDK/" && \
97+ cp -r /tmp/web-dist "$PNPM_WEB_SDK/dist" ; \
98+ fi && \
99+ rm -rf /tmp/pkg-bundler /tmp/pkg-node /tmp/web-dist
100+
101+ # Copy sdk-4337 built files to .pnpm directory structure
102+ COPY --from=builder /usr/src/app/packages/sdk-4337/dist /tmp/sdk-4337-dist
103+ RUN PNPM_SDK_4337=$(find /prod/auth-server-api/node_modules/.pnpm -type d -name "zksync-sso-4337" 2>/dev/null | head -1) && \
104+ if [ -n "$PNPM_SDK_4337" ]; then \
105+ cp -r /tmp/sdk-4337-dist "$PNPM_SDK_4337/dist" ; \
106+ fi && \
107+ rm -rf /tmp/sdk-4337-dist
80108
81109WORKDIR /prod/auth-server-api
82110
@@ -86,7 +114,7 @@ ENV NODE_ENV=production
86114
87115# Healthcheck
88116HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
89- CMD ["node " , "-e " , "require(' http').get('http ://localhost:3004/api/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1)) " ]
117+ CMD ["curl " , "-f " , "http://localhost:3004/api/health" ]
90118
91119# Expose port
92120EXPOSE 3004
0 commit comments