@@ -39,6 +39,7 @@ root_dir="`dirname $src_dir`"
39
39
source " $ci_dir /shared.sh"
40
40
41
41
if isCI; then
42
+ echo " CI detected"
42
43
objdir=$root_dir /obj
43
44
else
44
45
objdir=$root_dir /obj/$image
53
54
CACHE_DOMAIN=" ${CACHE_DOMAIN:- ci-caches.rust-lang.org} "
54
55
55
56
if [ -f " $docker_dir /$image /Dockerfile" ]; then
57
+ echo " Dockerfile found for $image "
56
58
hash_key=/tmp/.docker-hash-key.txt
57
59
rm -f " ${hash_key} "
58
60
echo $image >> $hash_key
@@ -153,6 +155,7 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
153
155
--output=type=docker
154
156
# On auto/try builds, we can also write to the cache.
155
157
else
158
+ echo " Logging into the Docker registry"
156
159
# Log into the Docker registry, so that we can read/write cache and the final image
157
160
echo ${DOCKER_TOKEN} | docker login ${REGISTRY} \
158
161
--username ${REGISTRY_USERNAME} \
@@ -163,6 +166,7 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
163
166
docker buildx create --use --driver docker-container \
164
167
--driver-opt image=${GHCR_BUILDKIT_IMAGE}
165
168
169
+ echo " Building Docker image with cache"
166
170
# Build the image using registry caching backend
167
171
retry docker \
168
172
buildx \
@@ -171,11 +175,13 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
171
175
--cache-to type=registry,ref=${CACHE_IMAGE_TAG} ,compression=zstd \
172
176
--output=type=docker
173
177
178
+ echo " Docker image built"
174
179
# Print images for debugging purposes
175
180
docker images
176
181
177
182
# Tag the built image and push it to the registry
178
183
docker tag rust-ci " ${IMAGE_TAG} "
184
+ echo " Pushing Docker image to the registry"
179
185
docker push " ${IMAGE_TAG} "
180
186
181
187
# Record the container registry tag/url for reuse, e.g. by rustup.rs builds
227
233
exit 1
228
234
fi
229
235
236
+ echo " Creating directories"
230
237
mkdir -p $HOME /.cargo
231
238
mkdir -p $objdir /tmp
232
239
mkdir -p $objdir /cores
@@ -282,24 +289,32 @@ args="$args --privileged"
282
289
# `LOCAL_USER_ID` (recognized in `src/ci/run.sh`) to ensure that files are all
283
290
# read/written as the same user as the bare-metal user.
284
291
if [ -f /.dockerenv ]; then
285
- docker create -v /checkout --name checkout alpine:3.4 /bin/true
292
+ echo " Dockerenv detected. We are in docker-in-docker scenario."
293
+ docker create -v /checkout --name checkout ghcr.io/marcoieni/alpine:3.4 /bin/true
286
294
docker cp . checkout:/checkout
287
295
args=" $args --volumes-from checkout"
288
296
else
289
297
args=" $args --volume $root_dir :/checkout$SRC_MOUNT_OPTION "
290
298
args=" $args --volume $objdir :/checkout/obj"
291
299
args=" $args --volume $HOME /.cargo:/cargo"
292
300
args=" $args --volume /tmp/toolstate:/tmp/toolstate"
301
+ fi
293
302
294
- id=$( id -u)
295
- if [[ " $id " != 0 && " $( docker version) " =~ Podman ]]; then
296
- # Rootless podman creates a separate user namespace, where an inner
297
- # LOCAL_USER_ID will map to a different subuid range on the host.
298
- # The "keep-id" mode maps the current UID directly into the container.
299
- args=" $args --env NO_CHANGE_USER=1 --userns=keep-id"
300
- else
301
- args=" $args --env LOCAL_USER_ID=$id "
302
- fi
303
+ id=$( id -u)
304
+ if [[ " $id " != 0 && " $( docker version) " =~ Podman ]]; then
305
+ # Rootless podman creates a separate user namespace, where an inner
306
+ # LOCAL_USER_ID will map to a different subuid range on the host.
307
+ # The "keep-id" mode maps the current UID directly into the container.
308
+ echo " Running in rootless podman"
309
+ args=" $args --env NO_CHANGE_USER=1 --userns=keep-id"
310
+ elif [[ " $id " != 0 ]]; then
311
+ echo " Running in docker as non-root"
312
+ args=" $args --env LOCAL_USER_ID=$id "
313
+ else
314
+ echo " Running in docker as root. Using id 1001."
315
+ # If we're running as root, we don't want to run the container as root,
316
+ # so we set id `1001` instead of `0`.
317
+ args=" $args --env LOCAL_USER_ID=1001"
303
318
fi
304
319
305
320
if [ " $dev " = " 1" ]
0 commit comments