Skip to content

Latest commit

 

History

History
87 lines (68 loc) · 2.57 KB

File metadata and controls

87 lines (68 loc) · 2.57 KB

OpenSSL Conflict Resolution Guide

Problem

You're encountering this error during Docker build:

Error: openssl-snapsafe-libs conflicts with 1:openssl-libs-1.0.2k-24.amzn2.0.16.x86_64
You could try using --skip-broken to work around the problem

Root Cause

Amazon Linux 2 has conflicting OpenSSL packages between openssl-snapsafe-libs and openssl-libs. This is a known issue when building Docker images on AL2.

Solutions Applied

1. Updated Dockerfile

  • Removed openssl-devel from the main package installation
  • Added separate OpenSSL installation with conflict resolution
  • Uses --skip-broken flag to handle conflicts gracefully

2. Created Retry Build Script

  • scripts/build-with-retry.sh - Handles build failures with retry logic
  • Automatically retries failed builds up to 3 times
  • Provides better error handling and logging

How to Use

Option 1: Use the Updated Dockerfile

The Dockerfile now handles OpenSSL conflicts automatically:

docker buildx build --platform=linux/amd64 -f dockerfiles/Dockerfile -t ghcr.io/aarondd/lambda-gdal:3.8 .

Option 2: Use the Retry Script

Use the new retry script for more robust builds:

./scripts/build-with-retry.sh 3.8.3 3.12

Option 3: Manual Conflict Resolution

If you still encounter issues, try this manual approach:

# Build with skip-broken flag
docker buildx build \
  --platform=linux/amd64 \
  --build-arg GDAL_VERSION=3.8.3 \
  -f dockerfiles/Dockerfile \
  -t ghcr.io/aarondd/lambda-gdal:3.8 \
  --push .

Alternative Approaches

Use Different Base Image

If OpenSSL conflicts persist, consider using a different base:

# Alternative: Use Amazon Linux 2023 instead of AL2
FROM public.ecr.aws/lambda/provided:al2023 AS builder

Multi-stage Build Optimization

The current Dockerfile uses multi-stage builds which should help isolate the OpenSSL installation.

Testing the Fix

  1. Test the build locally first:

    docker build -f dockerfiles/Dockerfile -t test-gdal .
  2. If successful, push to registry:

    ./scripts/build-with-retry.sh 3.8.3 3.12
  3. Verify the image works:

    docker run --rm ghcr.io/aarondd/lambda-gdal:3.8 gdal-config --version

Prevention

  • Always test builds locally before pushing
  • Use the retry script for production builds
  • Monitor for OpenSSL package updates in Amazon Linux 2
  • Consider migrating to Amazon Linux 2023 when available for Lambda

The updated Dockerfile should resolve the OpenSSL conflict issue you encountered! 🚀