dev_1.0.0_yuyr 完成 log和bind模块开发部署测试 #8

Merged
yuyr merged 26 commits from dev_1.0.0_yuyr into dev_1.0.0 2025-09-22 16:39:39 +08:00
2 changed files with 89 additions and 45 deletions
Showing only changes of commit 05bfde9d37 - Show all commits

View File

@ -4,6 +4,18 @@ FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Shanghai ENV TZ=Asia/Shanghai
# 设置构建参数
ARG USE_INTRANET=false
# 配置内网 apt 源 (如果指定了内网选项)
RUN if [ "$USE_INTRANET" = "true" ]; then \
echo "Configuring intranet apt sources..." && \
cp /etc/apt/sources.list /etc/apt/sources.list.bak && \
echo "deb [trusted=yes] http://10.68.64.1/ubuntu2204/ jammy main" > /etc/apt/sources.list && \
echo 'Acquire::https::Verify-Peer "false";' > /etc/apt/apt.conf.d/99disable-ssl-check && \
echo 'Acquire::https::Verify-Host "false";' >> /etc/apt/apt.conf.d/99disable-ssl-check; \
fi
# Update package list and install required packages # Update package list and install required packages
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y \ apt-get install -y \
@ -11,9 +23,17 @@ RUN apt-get update && \
bind9utils \ bind9utils \
bind9-doc \ bind9-doc \
supervisor \ supervisor \
net-tools \
inetutils-ping \
vim \
&& apt-get clean \ && apt-get clean \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# 配置部署时使用的apt源
RUN if [ "$USE_INTRANET" = "true" ]; then \
echo "deb [trusted=yes] https://10.92.132.52/mirrors/ubuntu2204/ jammy main" > /etc/apt/sources.list; \
fi
# Create supervisor configuration directory # Create supervisor configuration directory
RUN mkdir -p /etc/supervisor/conf.d RUN mkdir -p /etc/supervisor/conf.d

View File

@ -1,74 +1,98 @@
#!/bin/bash #!/usr/bin/env bash
set -euo pipefail
# Build BIND DNS container image # 帮助信息
# Usage: ./build_images.sh [--intranet] show_help() {
cat << EOF
ARGUS BIND9 DNS System - Image Build Tool
set -e Usage: $0 [OPTIONS]
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" Options:
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" --intranet Use intranet mirror for Ubuntu 22.04 packages
BUILD_DIR="$PROJECT_ROOT/build" -h, --help Show this help message
IMAGE_NAME="argus-bind9" Examples:
TAG="latest" $0 # Build with default sources
$0 --intranet # Build with intranet mirror
EOF
}
# 解析命令行参数
use_intranet=false
# Parse command line arguments
USE_INTRANET=false
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case $1 in case $1 in
--intranet) --intranet)
USE_INTRANET=true use_intranet=true
shift shift
;; ;;
-h|--help)
show_help
exit 0
;;
*) *)
echo "Unknown option: $1" echo "Unknown option: $1"
echo "Usage: $0 [--intranet]" show_help
exit 1 exit 1
;; ;;
esac esac
done done
echo "Building BIND9 DNS container image..." root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
echo "Image: $IMAGE_NAME:$TAG" cd "$root"
echo "Build directory: $BUILD_DIR"
# Check if build directory exists echo "======================================="
if [ ! -d "$BUILD_DIR" ]; then echo "ARGUS BIND9 DNS System - Image Build Tool"
echo "Error: Build directory not found: $BUILD_DIR" echo "======================================="
exit 1
if [[ "$use_intranet" == true ]]; then
echo "🌐 Mode: Intranet (Using internal mirror: 10.68.64.1)"
build_args="--build-arg USE_INTRANET=true"
else
echo "🌐 Mode: Public (Using default package sources)"
build_args=""
fi fi
# Check if Dockerfile exists echo ""
if [ ! -f "$BUILD_DIR/Dockerfile" ]; then
echo "Error: Dockerfile not found: $BUILD_DIR/Dockerfile"
exit 1
fi
cd "$BUILD_DIR" # 构建 BIND9 镜像
echo "🔄 Building BIND9 DNS container image..."
echo "Image: argus-bind9:latest"
echo "Build directory: $root/build"
if [ "$USE_INTRANET" = true ]; then if [[ "$use_intranet" == true ]]; then
echo "Building with intranet apt source (10.68.64.1)..." echo "Building with intranet mirror sources..."
# Create temporary Dockerfile with intranet apt source
cp Dockerfile Dockerfile.tmp
# Insert intranet apt configuration after the FROM line
sed -i '/^FROM ubuntu:22.04/a\\n# Configure intranet apt source\nRUN echo "deb [trusted=yes] http://10.68.64.1/ubuntu2204/ jammy main" > /etc/apt/sources.list && \\\n mkdir -p /etc/apt/apt.conf.d && \\\n echo "Acquire::https::Verify-Peer \"false\";" > /etc/apt/apt.conf.d/99-disable-ssl-verify && \\\n echo "Acquire::https::Verify-Host \"false\";" >> /etc/apt/apt.conf.d/99-disable-ssl-verify' Dockerfile.tmp
# Build with modified Dockerfile
docker build -f Dockerfile.tmp -t "$IMAGE_NAME:$TAG" .
# Clean up temporary file
rm -f Dockerfile.tmp
else else
echo "Building with default public apt sources..." echo "Building with default public apt sources..."
docker build -t "$IMAGE_NAME:$TAG" .
fi fi
echo "Build completed successfully!" if docker build $build_args -t argus-bind9:latest ./build; then
echo "Image: $IMAGE_NAME:$TAG" echo "✅ Build completed successfully!"
else
echo "❌ Failed to build BIND9 image"
exit 1
fi
echo ""
echo "======================================="
echo "📦 Build Summary"
echo "======================================="
echo "✅ Successfully built image:"
echo " • argus-bind9:latest"
if [[ "$use_intranet" == true ]]; then
echo ""
echo "🌐 Built with intranet mirror configuration"
fi
# Show image info
echo "" echo ""
echo "Image details:" echo "Image details:"
docker images "$IMAGE_NAME:$TAG" docker images argus-bind9:latest
echo ""
echo "🚀 Next steps:"
echo " ./scripts/save_images.sh # Export images"
echo " cd tests && ./scripts/00_e2e_test.sh # Run tests"
echo ""