Laravel 第一版 git 會沒成功 20250602

This commit is contained in:
allen.yan 2025-06-02 16:00:40 +08:00
parent e36fd90a91
commit caf05911c2
2 changed files with 9 additions and 8 deletions

View File

@ -5,7 +5,7 @@ services:
dockerfile: Dockerfile.git
container_name: git_worker
volumes:
- ./data/html:/app
- ./data:/app
- ./data/logs/git/:/var/log/
environment:
- REPO_URL=${REPO_URL}

View File

@ -1,20 +1,21 @@
#!/bin/bash
REPO_URL=${REPO_URL:-https://github.com/your/repo.git}
BRANCH=${BRANCH:-main}
REPO_URL=${REPO_URL}
BRANCH=${BRANCH}
TARGET_DIR=/app/html
# 若資料夾為空則 clone
if [ -z "$(ls -A /app | grep -v 'entrypoint.sh')" ]; then
echo "[git-worker] Cloning repository..."
git clone --branch "$BRANCH" "$REPO_URL" /app
if [ -z "$(ls -A "$TARGET_DIR")" ]; then
echo "[git-worker] Cloning repository into $TARGET_DIR..."
git clone --branch "$BRANCH" "$REPO_URL" "$TARGET_DIR"
else
echo "[git-worker] Repository exists, skipping clone."
echo "[git-worker] Repository exists in $TARGET_DIR, skipping clone."
fi
# 定時 git pull
echo "[git-worker] Starting periodic git pull..."
while true; do
cd /app
cd "$TARGET_DIR" || exit
echo "[git-worker] Pulling latest changes from $BRANCH..."
git pull origin "$BRANCH"
sleep 300