@@ -46,90 +46,6 @@ RUN mkdir -p /prod_bundle && \
4646 cd /prod_bundle && \
4747 npm install --production
4848
49- # =================================================================
50- # Stage 3: Fetch Redroid Docker image (redroid-fetcher)
51- # =================================================================
52- FROM docker:28-dind AS redroid-fetcher
53-
54- # NOTE:
55- # This stage secures the build process by pulling a third-party image (Redroid)
56- # using an immutable digest (SHA-256 hash) instead of a mutable tag. This prevents
57- # supply chain attacks where a tag could be retargeted to a malicious image.
58- #
59- # To achieve this, it starts a Docker daemon inside the build environment
60- # (Docker-in-Docker), pulls the specified Redroid image, and saves it as a tarball.
61- #
62- # --- DOCKER-IN-DOCKER PRIVILEGE WARNING ---
63- # This approach requires the build environment to support running a Docker daemon with
64- # sufficient privileges (e.g., privileged containers with proper cgroup access). In
65- # many CI/CD or restricted environments, such privileges may not be available, which
66- # can cause this stage to fail due to permission or daemon startup issues.
67- #
68- # If you encounter build failures at this stage, a recommended and more secure
69- # alternative is to perform the pull and save manually on a trusted host machine:
70- #
71- # 1. On a host with Docker access, manually pull the image using its immutable
72- # digest. Choose the digest corresponding to your target architecture:
73- #
74- # # For linux/amd64 (most common for servers and PCs):
75- # docker pull redroid/redroid@sha256:d1ca0815eb68139a43d25a835e374559e9d18f5d5cea1a4288d4657c0074fb8d
76- #
77- # # For linux/arm64 (Apple M-series, Raspberry Pi, AWS Graviton, etc.):
78- # docker pull redroid/redroid@sha256:f070231146ba5043bdb225a1f51c77ef0765c1157131b26cb827078bf536c922
79- #
80- # 2. Then, save the pulled image to a tarball. Use the same digest as in step 1.
81- # (Example for amd64):
82- # docker save -o redroid.tar redroid/redroid@sha256:d1ca0815eb68139a43d25a835e374559e9d18f5d5cea1a4288d4657c0074fb8d
83- #
84- # 3. Place the resulting `redroid.tar` in the Docker build context (e.g., next to
85- # this Dockerfile, in a path like `src/agentscope_runtime/sandbox/box/mobile/`).
86- #
87- # 4. Remove or skip this `redroid-fetcher` stage entirely, and in the final stage,
88- # replace the line:
89- # COPY --from=redroid-fetcher /redroid.tar /redroid.tar
90- # with a direct copy from your build context:
91- # COPY src/agentscope_runtime/sandbox/box/mobile/redroid.tar /redroid.tar
92- #
93- # This avoids running Docker-in-Docker and is more compatible with restricted build
94- # environments, while still maintaining supply chain security.
95-
96- # Pin the redroid image to an immutable digest for security and reproducibility.
97- # The default digest is for the linux/amd64 architecture.
98- # To build for linux/arm64, pass the --build-arg flag to the docker build command:
99- # --build-arg REDROID_DIGEST=sha256:f070231146ba5043bdb225a1f51c77ef0765c1157131b26cb827078bf536c922
100- ARG REDROID_DIGEST=sha256:d1ca0815eb68139a43d25a835e374559e9d18f5d5cea1a4288d4657c0074fb8d
101-
102- # --- Display a warning to the user before the privileged operation ---
103- RUN echo "" && \
104- echo "========================================================================" && \
105- echo " >>> WARNING: Privileged Operation Ahead <<<" && \
106- echo "========================================================================" && \
107- echo "The following step will start a Docker-in-Docker (DinD) daemon." && \
108- echo "This operation requires high privileges (e.g., the --privileged flag)" && \
109- echo "and may fail in restricted environments like CI/CD pipelines." && \
110- echo "" && \
111- echo " --- IF THIS STEP FAILS, USE THE ALTERNATIVE BELOW ---" && \
112- echo "Manually 'docker pull' and 'docker save' the image to a .tar file, then" && \
113- echo "copy it into the build context. For detailed instructions, please refer" && \
114- echo "to the comments at the top of this stage in the Dockerfile:" && \
115- echo " src/agentscope_runtime/sandbox/box/mobile/Dockerfile" && \
116- echo "========================================================================" && \
117- echo ""
118-
119- # --- Run the Docker-in-Docker process ---
120- RUN dockerd-entrypoint.sh & \
121- TIMEOUT=30; \
122- while ! docker info > /dev/null 2>&1; do \
123- if [ $TIMEOUT -le 0 ]; then \
124- echo "Docker daemon did not become ready in time." >&2; \
125- exit 1; \
126- fi; \
127- sleep 1; \
128- TIMEOUT=$((TIMEOUT - 1)); \
129- done && \
130- docker pull redroid/redroid@${REDROID_DIGEST} && \
131- docker save -o /redroid.tar redroid/redroid@${REDROID_DIGEST}
132-
13349# =================================================================
13450# Final Stage: Production Image
13551# =================================================================
@@ -167,8 +83,13 @@ COPY src/agentscope_runtime/sandbox/box/mobile/box/mcp_server_configs.json /app/
16783COPY src/agentscope_runtime/sandbox/box/mobile/box/scripts/start.sh /start.sh
16884RUN chmod +x /start.sh
16985
170- # 6. Copy the offline redroid image from the fetcher stage
171- COPY --from=redroid-fetcher /redroid.tar /redroid.tar
86+ RUN echo "[BUILD NOTE] This step requires:" && \
87+ echo " 'src/agentscope_runtime/sandbox/box/mobile/redroid.tar'." && \
88+ echo "This file is generated by the build script ('build.py')." && \
89+ echo "If building manually, please prepare the necessary files."
90+ # 6. Copy the offline redroid image prepared by the build script
91+ # NOTE: The build.py script is responsible for creating this file in the build context.
92+ COPY src/agentscope_runtime/sandbox/box/mobile/redroid.tar /redroid.tar
17293
17394# 7. Set entrypoint
17495ENTRYPOINT ["/start.sh" ]
0 commit comments