배포 실행 파일 수정 DB 덤프 자동실행 추가
This commit is contained in:
@@ -3,6 +3,9 @@ set -euo pipefail
|
||||
|
||||
branch="${1:-main}"
|
||||
target_dir="${2:-/srv/egbim_homepage}"
|
||||
env_file="${3:-}"
|
||||
db_dump_path="${4:-egbim_DB.sql}"
|
||||
db_import_marker=".db_import_done"
|
||||
|
||||
mkdir -p "$target_dir"
|
||||
cd "$target_dir"
|
||||
@@ -15,4 +18,30 @@ else
|
||||
git reset --hard "origin/$branch"
|
||||
fi
|
||||
|
||||
docker compose up -d --build
|
||||
if [[ -n "$env_file" ]]; then
|
||||
cp "$env_file" .env
|
||||
fi
|
||||
|
||||
if [[ -f .env ]]; then
|
||||
set -a
|
||||
# shellcheck disable=SC1091
|
||||
source .env
|
||||
set +a
|
||||
fi
|
||||
|
||||
mkdir -p docker/mysql/init
|
||||
|
||||
docker compose up -d --build
|
||||
|
||||
if [[ -f "$db_dump_path" && ! -f "$db_import_marker" ]]; then
|
||||
for _ in $(seq 1 30); do
|
||||
if docker compose exec -T db mariadb-admin ping -h localhost -uroot "-p${MARIADB_ROOT_PASSWORD}" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
docker compose exec -T db mariadb-admin ping -h localhost -uroot "-p${MARIADB_ROOT_PASSWORD}" >/dev/null 2>&1
|
||||
docker compose exec -T db mariadb -u"${G5_MYSQL_USER}" "-p${G5_MYSQL_PASSWORD}" "${G5_MYSQL_DB}" < "$db_dump_path"
|
||||
touch "$db_import_marker"
|
||||
fi
|
||||
@@ -2,7 +2,20 @@
|
||||
set -euo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
remote_url="https://gitea.hmac.kr/b24014/egbim_homepage.git"
|
||||
remote_mode="${1:-https}"
|
||||
|
||||
case "$remote_mode" in
|
||||
https)
|
||||
remote_url="https://gitea.hmac.kr/b24014/egbim_homepage.git"
|
||||
;;
|
||||
ssh)
|
||||
remote_url="ssh://git@172.16.10.175:22/b24014/egbim_homepage.git"
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 [https|ssh]" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
cd "$repo_root"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user