You encountered this error during Docker build:
gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now
The issue occurs when:
- Network downloads fail silently (curl with
-sflag) - Incomplete or corrupted tar.gz files are downloaded
- The tar command receives empty or malformed input
Changed from:
curl -sfL URL | tar zxf - -C /tmp/dir --strip-components=1To:
for i in 1 2 3; do \
curl -fL URL -o /tmp/file.tar.gz && break || sleep 5; \
done \
&& tar zxf /tmp/file.tar.gz -C /tmp/dir --strip-components=1 \
&& rm -rf /tmp/file.tar.gz- Retry Logic: Downloads retry up to 3 times with 5-second delays
- Error Detection:
-fflag makes curl fail on HTTP errors - File Validation: Downloads to file first, then extracts
- Cleanup: Removes temporary tar.gz files after extraction
- libdeflate: Fixed with retry logic and proper error handling
- libpng: Fixed with retry logic and proper error handling
- GDAL: Fixed with retry logic and proper error handling
curl -sfL https://github.com/user/repo/archive/v1.0.tar.gz | tar zxf - -C /tmp/dir --strip-components=1-sflag hides errors- Pipe can fail silently
- No retry mechanism
for i in 1 2 3; do \
curl -fL https://github.com/user/repo/archive/v1.0.tar.gz -o /tmp/file.tar.gz && break || sleep 5; \
done \
&& tar zxf /tmp/file.tar.gz -C /tmp/dir --strip-components=1 \
&& rm -rf /tmp/file.tar.gz-fflag shows HTTP errors- Downloads to file first (validates download)
- Retry loop with delays
- Proper cleanup
docker buildx build --platform=linux/amd64 -f dockerfiles/Dockerfile -t test-gdal .Try building with more verbose output:
docker buildx build --platform=linux/amd64 --progress=plain -f dockerfiles/Dockerfile -t test-gdal ../scripts/build-with-retry.sh 3.8.3 3.12- Downloads now retry automatically
- Better error reporting
- Graceful failure handling
- Temporary files are cleaned up properly
- Better layer caching
- Reduced image size
The download issues should now be resolved! The retry logic and proper error handling will make your builds much more reliable. 🚀