I dont know what im doing
This commit is contained in:
55
build-pi.sh
55
build-pi.sh
@@ -83,8 +83,19 @@ build_container() {
|
||||
|
||||
# Choose the right Dockerfile
|
||||
if [ -f "Dockerfile.pizero" ] && [[ "$ARCH" == "armv6l" ]]; then
|
||||
DOCKERFILE="Dockerfile.pizero"
|
||||
print_info "Using Pi Zero optimized Dockerfile"
|
||||
# Check if we need to use modern Python version
|
||||
if [ "${USE_MODERN_PYTHON}" = "true" ] || [ -f ".use-modern-python" ]; then
|
||||
if [ -f "Dockerfile.pizero-py312" ]; then
|
||||
DOCKERFILE="Dockerfile.pizero-py312"
|
||||
print_info "Using Pi Zero optimized Dockerfile with Python 3.12"
|
||||
else
|
||||
DOCKERFILE="Dockerfile.pizero"
|
||||
print_info "Using Pi Zero optimized Dockerfile with Python 3.11"
|
||||
fi
|
||||
else
|
||||
DOCKERFILE="Dockerfile.pizero"
|
||||
print_info "Using Pi Zero optimized Dockerfile with Python 3.11"
|
||||
fi
|
||||
elif [ -f "Dockerfile.minimal" ]; then
|
||||
DOCKERFILE="Dockerfile.minimal"
|
||||
print_info "Using minimal Dockerfile (no compilation)"
|
||||
@@ -97,7 +108,15 @@ build_container() {
|
||||
fi
|
||||
|
||||
# Build without memory limits (they may not be supported on all systems)
|
||||
# Force rebuild if requested
|
||||
BUILD_ARGS=""
|
||||
if [ "${FORCE_REBUILD}" = "true" ]; then
|
||||
BUILD_ARGS="--no-cache"
|
||||
print_info "Forcing rebuild without cache"
|
||||
fi
|
||||
|
||||
${RUNTIME} build \
|
||||
${BUILD_ARGS} \
|
||||
--file "${DOCKERFILE}" \
|
||||
--tag "${IMAGE_NAME}" \
|
||||
. || {
|
||||
@@ -185,6 +204,26 @@ show_logs() {
|
||||
${RUNTIME} logs -f ${CONTAINER_NAME}
|
||||
}
|
||||
|
||||
# Clean up old images and containers
|
||||
cleanup() {
|
||||
print_info "Cleaning up old containers and images..."
|
||||
|
||||
# Stop and remove container if it exists
|
||||
if ${RUNTIME} ps -a --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
|
||||
print_info "Stopping and removing old container..."
|
||||
${RUNTIME} stop ${CONTAINER_NAME} 2>/dev/null || true
|
||||
${RUNTIME} rm ${CONTAINER_NAME} 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Remove old image
|
||||
if ${RUNTIME} images --format '{{.Repository}}' | grep -q "^${IMAGE_NAME}$"; then
|
||||
print_info "Removing old image..."
|
||||
${RUNTIME} rmi ${IMAGE_NAME} 2>/dev/null || true
|
||||
fi
|
||||
|
||||
print_success "Cleanup complete!"
|
||||
}
|
||||
|
||||
# Main script
|
||||
case "${1:-build}" in
|
||||
build)
|
||||
@@ -198,6 +237,18 @@ case "${1:-build}" in
|
||||
run_container
|
||||
check_status
|
||||
;;
|
||||
clean-build)
|
||||
detect_system
|
||||
check_runtime
|
||||
cleanup
|
||||
FORCE_REBUILD=true
|
||||
build_container
|
||||
;;
|
||||
cleanup|clean)
|
||||
detect_system
|
||||
check_runtime
|
||||
cleanup
|
||||
;;
|
||||
start)
|
||||
detect_system
|
||||
check_runtime
|
||||
|
||||
Reference in New Issue
Block a user