Files
haiyushuke-website/scripts/docker/deploy-pull.sh
2026-06-16 14:34:09 +08:00

43 lines
1.1 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.

#!/usr/bin/env bash
# 部署机拉取 latest 并启动(对齐 bd-server/scripts/pull-main-on-deploy.sh
# 自测: curl -sI "https://docker-registry.tianyuanapi.com/v2/haiyushuke/website/manifests/latest"
#
# 用法:
# cp deploy.env.example deploy.env
# ./deploy-pull.sh
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
COMPOSE_FILE="${SCRIPT_DIR}/docker-compose.yml"
ENV_FILE="${ENV_FILE:-${SCRIPT_DIR}/deploy.env}"
if [[ ! -f "${ENV_FILE}" ]]; then
echo "missing ${ENV_FILE} (cp deploy.env.example deploy.env)" >&2
exit 1
fi
cd "${SCRIPT_DIR}"
echo "==> pull website (latest)"
docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" pull
echo "==> up -d website"
docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" up -d
# shellcheck disable=SC1090
set -a
source "${ENV_FILE}"
set +a
HOST_PORT="${HOST_PORT:-3000}"
echo "==> health http://127.0.0.1:${HOST_PORT}/"
sleep 2
if curl -fsS -o /dev/null "http://127.0.0.1:${HOST_PORT}/"; then
echo "OK"
else
echo "WARN: curl failed; docker compose logs -f website"
fi
echo "Done: ${REGISTRY}/${IMAGE_PATH}:latest"