From ba337b12aac6fcb2259f4f17c34985bab7b9e0c6 Mon Sep 17 00:00:00 2001 From: sevi-kun Date: Thu, 30 Oct 2025 16:16:33 +0100 Subject: [PATCH] fixing mem issue --- build-pi.sh | 60 +++++++++++++++++++++-------------------------------- 1 file changed, 24 insertions(+), 36 deletions(-) diff --git a/build-pi.sh b/build-pi.sh index 29b83f6..ad62bef 100755 --- a/build-pi.sh +++ b/build-pi.sh @@ -96,33 +96,23 @@ build_container() { exit 1 fi - # Build with memory limits for Pi Zero - if [[ "$ARCH" == "armv6l" ]] && [ $TOTAL_MEM_MB -lt 512 ]; then - print_warning "Building with memory constraints..." - ${RUNTIME} build \ - --memory-swap -1 \ - --file "${DOCKERFILE}" \ - --tag "${IMAGE_NAME}" \ - . || { - print_error "Build failed!" - print_info "Try these solutions:" + # Build without memory limits (they may not be supported on all systems) + ${RUNTIME} build \ + --file "${DOCKERFILE}" \ + --tag "${IMAGE_NAME}" \ + . || { + print_error "Build failed!" + if [ $TOTAL_MEM_MB -lt 512 ]; then + print_info "Try these solutions for low memory:" echo " 1. Add swap space:" echo " sudo dd if=/dev/zero of=/swapfile bs=1M count=1024" echo " sudo mkswap /swapfile" echo " sudo swapon /swapfile" echo " 2. Use pre-built image:" echo " ${RUNTIME} pull docker.io/yourusername/turmli-calendar:armv6" - exit 1 - } - else - ${RUNTIME} build \ - --file "${DOCKERFILE}" \ - --tag "${IMAGE_NAME}" \ - . || { - print_error "Build failed!" - exit 1 - } - fi + fi + exit 1 + } print_success "Container image built successfully!" } @@ -144,27 +134,25 @@ run_container() { print_info "Created cache file" fi - # Run with appropriate resource limits for Pi - if [[ "$ARCH" == "armv6l" ]] && [ $TOTAL_MEM_MB -lt 512 ]; then - print_info "Running with memory constraints..." - ${RUNTIME} run -d \ - --name ${CONTAINER_NAME} \ - --memory 256m \ - --memory-swap -1 \ - -p 8000:8000 \ - -v $(pwd)/calendar_cache.json:/app/calendar_cache.json:Z \ - -e TZ=Europe/Berlin \ - --restart unless-stopped \ - ${IMAGE_NAME} - else + # Run container (without memory limits as they may not be supported) + print_info "Starting container..." + ${RUNTIME} run -d \ + --name ${CONTAINER_NAME} \ + -p 8000:8000 \ + -v $(pwd)/calendar_cache.json:/app/calendar_cache.json:Z \ + -e TZ=Europe/Berlin \ + --restart unless-stopped \ + ${IMAGE_NAME} || { + # If it fails with :Z flag (SELinux label), try without it + print_warning "Retrying without SELinux labels..." ${RUNTIME} run -d \ --name ${CONTAINER_NAME} \ -p 8000:8000 \ - -v $(pwd)/calendar_cache.json:/app/calendar_cache.json:Z \ + -v $(pwd)/calendar_cache.json:/app/calendar_cache.json \ -e TZ=Europe/Berlin \ --restart unless-stopped \ ${IMAGE_NAME} - fi + } print_success "Container started!" print_info "Access the calendar at: http://$(hostname -I | awk '{print $1}'):8000"