Run LocalStack as managed Docker step for better resource control
parent
56efd54765
commit
2e93ecc896
|
|
@ -43,40 +43,76 @@ jobs:
|
|||
run: |
|
||||
curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
|
||||
k3d version | cat
|
||||
- name: Start LocalStack (S3)
|
||||
uses: localstack/setup-localstack@v0.2.4
|
||||
with:
|
||||
install-awslocal: true
|
||||
- name: Verify LocalStack is running
|
||||
- name: Clean up host disk space and prepare for k3d and LocalStack
|
||||
run: |
|
||||
echo "Checking LocalStack status..."
|
||||
curl -s http://localhost:4566/_localstack/health | head -10 || echo "LocalStack health check failed"
|
||||
# Check if LocalStack container is running
|
||||
docker ps | grep localstack || echo "No LocalStack container found"
|
||||
# Show LocalStack container network info
|
||||
docker ps --format "{{.Names}}" | grep -i localstack | head -1 | xargs -I {} docker inspect {} --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' || echo "Could not get LocalStack IP"
|
||||
- name: Create S3 bucket for tests (host LocalStack)
|
||||
run: |
|
||||
awslocal s3 mb s3://$AWS_STACK_NAME || true
|
||||
awslocal s3 ls
|
||||
- name: Clean up host disk space before creating k3d cluster
|
||||
run: |
|
||||
echo "Cleaning up host disk space before creating k3d cluster..."
|
||||
echo "Cleaning up host disk space before creating k3d cluster and LocalStack..."
|
||||
echo "Current disk usage:"
|
||||
df -h
|
||||
# Clean up any leftover k3d clusters/images from previous runs first
|
||||
k3d cluster delete unity-builder || true
|
||||
k3d image delete --all || true
|
||||
# Clean up Docker images and containers on host to free space for k3d
|
||||
# Stop any existing LocalStack container
|
||||
docker stop localstack-main 2>/dev/null || true
|
||||
docker rm localstack-main 2>/dev/null || true
|
||||
# Clean up Docker images and containers on host to free space
|
||||
# This is critical: k3d nodes share the host's disk, so we need space BEFORE creating the cluster
|
||||
# Note: We use --filter "until=24h" to avoid removing LocalStack which was just started
|
||||
docker system prune -af --volumes --filter "until=24h" || true
|
||||
# Remove unused images (keep images used by running containers like LocalStack)
|
||||
docker system prune -af --volumes || true
|
||||
# Remove unused images
|
||||
docker image prune -af || true
|
||||
# Remove unused volumes (but keep volumes used by running containers)
|
||||
# Remove unused volumes
|
||||
docker volume prune -f || true
|
||||
echo "Disk usage after cleanup:"
|
||||
df -h
|
||||
- name: Start LocalStack (S3) as managed Docker container
|
||||
run: |
|
||||
echo "Starting LocalStack as managed Docker container..."
|
||||
# Start LocalStack with specific name and resource limits
|
||||
docker run -d \
|
||||
--name localstack-main \
|
||||
--network bridge \
|
||||
-p 4566:4566 \
|
||||
-e SERVICES=s3,cloudformation,ecs,kinesis,cloudwatch,logs \
|
||||
-e DEBUG=0 \
|
||||
-e DATA_DIR=/tmp/localstack/data \
|
||||
--tmpfs /tmp/localstack/data:rw,noexec,nosuid,size=100m \
|
||||
localstack/localstack:latest || true
|
||||
# Wait for LocalStack to be ready
|
||||
echo "Waiting for LocalStack to be ready..."
|
||||
for i in {1..30}; do
|
||||
if curl -s http://localhost:4566/_localstack/health > /dev/null 2>&1; then
|
||||
echo "LocalStack is ready (attempt $i/30)"
|
||||
break
|
||||
fi
|
||||
echo "Waiting for LocalStack... ($i/30)"
|
||||
sleep 2
|
||||
done
|
||||
# Verify LocalStack is running
|
||||
echo "Checking LocalStack status..."
|
||||
curl -s http://localhost:4566/_localstack/health | head -10 || echo "LocalStack health check failed"
|
||||
docker ps | grep localstack || echo "No LocalStack container found"
|
||||
- name: Install AWS CLI tools
|
||||
run: |
|
||||
# Install AWS CLI if not already available
|
||||
if ! command -v aws > /dev/null 2>&1; then
|
||||
pip install awscli || true
|
||||
fi
|
||||
# Install awscli-local for convenience (optional)
|
||||
pip install awscli-local || true
|
||||
aws --version || echo "AWS CLI not available"
|
||||
awslocal --version || echo "awslocal not available, will use aws CLI with endpoint-url"
|
||||
- name: Create S3 bucket for tests (host LocalStack)
|
||||
run: |
|
||||
# Use awslocal if available, otherwise use aws CLI with endpoint-url
|
||||
if command -v awslocal > /dev/null 2>&1; then
|
||||
awslocal s3 mb s3://$AWS_STACK_NAME || true
|
||||
awslocal s3 ls
|
||||
elif command -v aws > /dev/null 2>&1; then
|
||||
aws --endpoint-url=http://localhost:4566 s3 mb s3://$AWS_STACK_NAME || true
|
||||
aws --endpoint-url=http://localhost:4566 s3 ls || true
|
||||
else
|
||||
echo "Neither awslocal nor aws CLI available"
|
||||
exit 1
|
||||
fi
|
||||
- name: Create k3s cluster (k3d)
|
||||
timeout-minutes: 5
|
||||
run: |
|
||||
|
|
|
|||
Loading…
Reference in New Issue