fixing mem issue

This commit is contained in:
2025-10-30 16:16:33 +01:00
parent 532aef0f78
commit ba337b12aa

View File

@@ -96,33 +96,23 @@ build_container() {
exit 1 exit 1
fi fi
# Build with memory limits for Pi Zero # Build without memory limits (they may not be supported on all systems)
if [[ "$ARCH" == "armv6l" ]] && [ $TOTAL_MEM_MB -lt 512 ]; then ${RUNTIME} build \
print_warning "Building with memory constraints..." --file "${DOCKERFILE}" \
${RUNTIME} build \ --tag "${IMAGE_NAME}" \
--memory-swap -1 \ . || {
--file "${DOCKERFILE}" \ print_error "Build failed!"
--tag "${IMAGE_NAME}" \ if [ $TOTAL_MEM_MB -lt 512 ]; then
. || { print_info "Try these solutions for low memory:"
print_error "Build failed!"
print_info "Try these solutions:"
echo " 1. Add swap space:" echo " 1. Add swap space:"
echo " sudo dd if=/dev/zero of=/swapfile bs=1M count=1024" echo " sudo dd if=/dev/zero of=/swapfile bs=1M count=1024"
echo " sudo mkswap /swapfile" echo " sudo mkswap /swapfile"
echo " sudo swapon /swapfile" echo " sudo swapon /swapfile"
echo " 2. Use pre-built image:" echo " 2. Use pre-built image:"
echo " ${RUNTIME} pull docker.io/yourusername/turmli-calendar:armv6" echo " ${RUNTIME} pull docker.io/yourusername/turmli-calendar:armv6"
exit 1 fi
} exit 1
else }
${RUNTIME} build \
--file "${DOCKERFILE}" \
--tag "${IMAGE_NAME}" \
. || {
print_error "Build failed!"
exit 1
}
fi
print_success "Container image built successfully!" print_success "Container image built successfully!"
} }
@@ -144,27 +134,25 @@ run_container() {
print_info "Created cache file" print_info "Created cache file"
fi fi
# Run with appropriate resource limits for Pi # Run container (without memory limits as they may not be supported)
if [[ "$ARCH" == "armv6l" ]] && [ $TOTAL_MEM_MB -lt 512 ]; then print_info "Starting container..."
print_info "Running with memory constraints..." ${RUNTIME} run -d \
${RUNTIME} run -d \ --name ${CONTAINER_NAME} \
--name ${CONTAINER_NAME} \ -p 8000:8000 \
--memory 256m \ -v $(pwd)/calendar_cache.json:/app/calendar_cache.json:Z \
--memory-swap -1 \ -e TZ=Europe/Berlin \
-p 8000:8000 \ --restart unless-stopped \
-v $(pwd)/calendar_cache.json:/app/calendar_cache.json:Z \ ${IMAGE_NAME} || {
-e TZ=Europe/Berlin \ # If it fails with :Z flag (SELinux label), try without it
--restart unless-stopped \ print_warning "Retrying without SELinux labels..."
${IMAGE_NAME}
else
${RUNTIME} run -d \ ${RUNTIME} run -d \
--name ${CONTAINER_NAME} \ --name ${CONTAINER_NAME} \
-p 8000:8000 \ -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 \ -e TZ=Europe/Berlin \
--restart unless-stopped \ --restart unless-stopped \
${IMAGE_NAME} ${IMAGE_NAME}
fi }
print_success "Container started!" print_success "Container started!"
print_info "Access the calendar at: http://$(hostname -I | awk '{print $1}'):8000" print_info "Access the calendar at: http://$(hostname -I | awk '{print $1}'):8000"