-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage_release_from_image.sh
More file actions
175 lines (151 loc) · 6.59 KB
/
Copy pathpackage_release_from_image.sh
File metadata and controls
175 lines (151 loc) · 6.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/bin/bash
# Package a release from an existing Docker image tarball.
#
# This script does not build an image. Use it after exporting an image from a
# target-compatible host, for example:
# ssh snail 'docker save agenticsre:latest | gzip > /tmp/agenticsre-image.tar.gz'
# scp snail:/tmp/agenticsre-image.tar.gz /tmp/agenticsre-image.tar.gz
# IMAGE_TAR_PATH=/tmp/agenticsre-image.tar.gz ./package_release_from_image.sh
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "${SCRIPT_DIR}"
IMAGE_NAME="${IMAGE_NAME:-agenticsre}"
IMAGE_TAG="${IMAGE_TAG:-latest}"
IMAGE_REF="${IMAGE_NAME}:${IMAGE_TAG}"
IMAGE_TAR_PATH="${IMAGE_TAR_PATH:-/tmp/agenticsre-image.tar.gz}"
IMAGE_META_PATH="${IMAGE_META_PATH:-/tmp/agenticsre-image-meta.txt}"
IMAGE_TAR="agenticsre-image.tar.gz"
SOURCE_TAR="agenticsre-source.tar.gz"
RELEASE_DATE="$(date +%Y%m%d)"
RELEASE_NAME="${RELEASE_NAME:-agenticsre-release-${RELEASE_DATE}}"
STAGING_DIR="${SCRIPT_DIR}/release/${RELEASE_NAME}"
RELEASE_TAR="${SCRIPT_DIR}/${RELEASE_NAME}.tar.gz"
GIT_BRANCH="$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)"
GIT_COMMIT="$(git rev-parse --short HEAD 2>/dev/null || echo unknown)"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
info() { echo -e "${GREEN}[INFO]${NC} $*"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
error() { echo -e "${RED}[ERROR]${NC} $*"; exit 1; }
[ -f "${IMAGE_TAR_PATH}" ] || error "Image tar not found: ${IMAGE_TAR_PATH}"
info "Creating release staging directory..."
rm -rf "${STAGING_DIR}"
mkdir -p "${STAGING_DIR}"
info "Copying exported Docker image..."
cp "${IMAGE_TAR_PATH}" "${STAGING_DIR}/${IMAGE_TAR}"
if [ -f "${IMAGE_META_PATH}" ]; then
cp "${IMAGE_META_PATH}" "${STAGING_DIR}/IMAGE_META.txt"
fi
info "Creating source snapshot from current workspace..."
tar --exclude='.venv' \
--exclude='__pycache__' \
--exclude='*.pyc' \
--exclude='.git' \
--exclude='.claude' \
--exclude='.pycache_tmp' \
--exclude='.DS_Store' \
--exclude='*/.DS_Store' \
--exclude='data' \
--exclude='logs' \
--exclude='.env' \
--exclude='docker-compose.yaml' \
--exclude='*.tar' \
--exclude='*.tar.gz' \
--exclude='*.tgz' \
--exclude='release' \
--exclude='hermes-agent' \
--exclude='运维多智能体协作技术研究项目SOW.docx' \
--exclude='*SOW*' \
--exclude='*sow*' \
--exclude='eval/results/*' \
-czf "${STAGING_DIR}/${SOURCE_TAR}" .
info "Copying deployment files..."
cp Dockerfile .dockerignore docker-compose.release.yaml deploy_docker.sh build_release.sh build_release_from_remote_image.sh package_release_from_image.sh README.md USER_MANUAL.md AGENTS.md requirements.txt .env.example "${STAGING_DIR}/"
cp docker-compose.release.yaml "${STAGING_DIR}/docker-compose.yaml"
cp main.py mcp_server.py "${STAGING_DIR}/"
cp -R agents "${STAGING_DIR}/agents"
cp -R configs "${STAGING_DIR}/configs"
cp -R eval "${STAGING_DIR}/eval"
cp -R memory "${STAGING_DIR}/memory"
cp -R observability "${STAGING_DIR}/observability"
cp -R orchestrator "${STAGING_DIR}/orchestrator"
cp -R paradigms "${STAGING_DIR}/paradigms"
cp -R tools "${STAGING_DIR}/tools"
cp -R web_app "${STAGING_DIR}/web_app"
cp -R tests "${STAGING_DIR}/tests"
cp -R doc "${STAGING_DIR}/doc"
cp -R report "${STAGING_DIR}/report"
cp -R 测试 "${STAGING_DIR}/测试"
cp -R vllm_fault_injector "${STAGING_DIR}/vllm_fault_injector"
find "${STAGING_DIR}" -type d -name __pycache__ -prune -exec rm -rf {} +
rm -rf "${STAGING_DIR}/eval/results"
mkdir -p "${STAGING_DIR}/eval/results"
touch "${STAGING_DIR}/eval/results/.gitkeep"
find "${STAGING_DIR}" -name .DS_Store -delete
find "${STAGING_DIR}" -name '._*' -delete
chmod +x "${STAGING_DIR}/deploy_docker.sh" "${STAGING_DIR}/build_release.sh" "${STAGING_DIR}/build_release_from_remote_image.sh" "${STAGING_DIR}/package_release_from_image.sh"
cat > "${STAGING_DIR}/RELEASE_NOTES.md" <<EOF
# AgenticSRE Release ${RELEASE_DATE}
This package was created from an exported Docker image and the current source snapshot.
## Image
- Image reference: \`${IMAGE_REF}\`
- Image tar: \`${IMAGE_TAR}\`
- Image source: \`${IMAGE_TAR_PATH}\`
- Image metadata: \`IMAGE_META.txt\` when available
- Source snapshot: \`${GIT_BRANCH}@${GIT_COMMIT}\`
## Contents
- \`${IMAGE_TAR}\`: prebuilt Docker image
- \`${SOURCE_TAR}\`: source snapshot from the current workspace
- \`docker-compose.yaml\`: offline runtime Compose definition (no build section)
- \`deploy_docker.sh\`: one-command offline deployment helper
- Runtime source directories are included at package top level for bind mounts
- \`configs/\`: runtime configuration templates
- \`doc/\`, \`report/\`, \`测试/\`, \`tests/\`: local project documentation and test materials
- \`.env.example\`: environment variable template
- \`eval/\`: fault scenarios and evaluation utilities required by Web APIs
- \`SHA256SUMS\`: checksum file for package verification
- \`MANIFEST.txt\`: file list inside this release package
## Deploy
\`\`\`bash
tar xzf ${RELEASE_NAME}.tar.gz
cd ${RELEASE_NAME}
./deploy_docker.sh
\`\`\`
The release deploy script creates \`.env\` from \`.env.example\` when needed,
loads \`${IMAGE_TAR}\`, verifies the bundled runtime, and starts Compose with
\`--no-build\`. It should not download apt/pip dependencies during deployment.
Use \`./deploy_docker.sh --build\` only when an online rebuild is intentional.
Dashboard: http://localhost:8080
Health: http://localhost:8080/api/health
EOF
info "Writing manifest and checksums..."
(
cd "${STAGING_DIR}"
find . -type f | sort > MANIFEST.txt
: > SHA256SUMS
if command -v shasum >/dev/null 2>&1; then
find . -type f ! -name SHA256SUMS | sort | while IFS= read -r file; do
shasum -a 256 "$file" >> SHA256SUMS
done
else
find . -type f ! -name SHA256SUMS | sort | while IFS= read -r file; do
sha256sum "$file" >> SHA256SUMS
done
fi
)
info "Creating release tarball..."
rm -f "${RELEASE_TAR}"
tar -czf "${RELEASE_TAR}" -C "${SCRIPT_DIR}/release" "${RELEASE_NAME}"
RELEASE_SIZE="$(du -h "${RELEASE_TAR}" | awk '{print $1}')"
IMAGE_SIZE="$(du -h "${STAGING_DIR}/${IMAGE_TAR}" | awk '{print $1}')"
SOURCE_SIZE="$(du -h "${STAGING_DIR}/${SOURCE_TAR}" | awk '{print $1}')"
echo ""
echo "═══════════════════════════════════════════"
info "Release package built from exported image."
echo " File: ${RELEASE_TAR}"
echo " Size: ${RELEASE_SIZE}"
echo " Image: ${IMAGE_SIZE}"
echo " Source: ${SOURCE_SIZE}"
echo "═══════════════════════════════════════════"