Files
FunMD_Convert/package_offline.sh
2026-01-07 17:18:26 +08:00

61 lines
1.6 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -euo pipefail
# Image naming
# 注意Docker 镜像名必须为小写且不含下划线,这里使用 funmd-convert
IMAGE_NAME="funmd-convert"
IMAGE_TAG="latest"
OUTPUT_DIR="$(pwd)"
# 导出的 tar 文件命名为项目名 FunMD_Convert 以便识别
OUTPUT_TAR="${OUTPUT_DIR}/FunMD_Convert.tar"
echo "[1/4] Building Docker image ${IMAGE_NAME}:${IMAGE_TAG}"
docker build -t ${IMAGE_NAME}:${IMAGE_TAG} .
echo "[2/4] Saving image to ${OUTPUT_TAR}"
docker save ${IMAGE_NAME}:${IMAGE_TAG} -o "${OUTPUT_TAR}"
echo "[3/4] Image size and sha256"
ls -lh "${OUTPUT_TAR}"
SHA256=$(shasum -a 256 "${OUTPUT_TAR}" | awk '{print $1}')
echo "sha256=${SHA256}"
cat <<'EON'
[4/4] Transfer and run on offline server:
1) 复制镜像包到服务器,例如 /opt/FunMD_Convert/FunMD_Convert.tar
scp FunMD_Convert.tar user@server:/opt/FunMD_Convert/
2) 加载镜像:
docker load -i /opt/FunMD_Convert/FunMD_Convert.tar
3) 验证镜像:
docker images | grep funmd-convert
4) 启动容器(后端端口 8000同时托管前端 /ui
docker run -d \
-p 8000:8000 \
--name FunMD_Convert \
--restart unless-stopped \
funmd-convert:${IMAGE_TAG}
5) 访问:
后端健康检查: http://<服务器IP>:8000/health
前端页面: http://<服务器IP>:8000/ui/
6) (可选)配置 MinIO
curl -X POST \
-F endpoint=10.9.35.31:9000 \
-F public=http://10.9.35.31:9000 \
-F access=你的AK \
-F secret=你的SK \
-F bucket=file-cms \
-F secure=false \
-F public_read=true \
http://<服务器IP>:8000/config/minio
EON
echo "[Done] Offline package ready: ${OUTPUT_TAR}"