try to fix deploy issue
This commit is contained in:
3
.env
3
.env
@ -1,13 +1,12 @@
|
|||||||
|
|
||||||
#NODE_TLS_REJECT_UNAUTHORIZED='0'
|
#NODE_TLS_REJECT_UNAUTHORIZED='0'
|
||||||
|
SSL_ENABLED=false
|
||||||
NEXT_PUBLIC_PROTOCOL=https
|
NEXT_PUBLIC_PROTOCOL=https
|
||||||
NEXT_PUBLIC_HOST=localhost
|
NEXT_PUBLIC_HOST=localhost
|
||||||
NEXT_PUBLIC_PORT=3003
|
NEXT_PUBLIC_PORT=3003
|
||||||
NEXTAUTH_URL=https://localhost:3003
|
NEXTAUTH_URL=https://localhost:3003
|
||||||
# NEXTAUTH_URL_INTERNAL=http://127.0.0.1:3003
|
# NEXTAUTH_URL_INTERNAL=http://127.0.0.1:3003
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Linux: `openssl rand -hex 32` or go to https://generate-secret.now.sh/32
|
# Linux: `openssl rand -hex 32` or go to https://generate-secret.now.sh/32
|
||||||
NEXTAUTH_SECRET=ed8a9681efc414df89dfd03cd188ed58
|
NEXTAUTH_SECRET=ed8a9681efc414df89dfd03cd188ed58
|
||||||
|
|
||||||
|
@ -5,56 +5,41 @@ if [ "$UPDATE_CODE_FROM_GIT" = "true" ]; then
|
|||||||
apk add git nano rsync
|
apk add git nano rsync
|
||||||
echo "Updating code from git.d-popov.com...(as '$GIT_USERNAME')"
|
echo "Updating code from git.d-popov.com...(as '$GIT_USERNAME')"
|
||||||
|
|
||||||
# Check for the current Git commit ID in the local copy
|
# Create a temporary directory for the new clone
|
||||||
CURRENT_GIT_COMMIT_ID=$(git -C /app rev-parse HEAD 2>/dev/null)
|
|
||||||
|
|
||||||
# Remove the previous clone directory to ensure a fresh start
|
|
||||||
rm -rf /tmp/clone
|
rm -rf /tmp/clone
|
||||||
mkdir /tmp/clone
|
mkdir /tmp/clone
|
||||||
|
|
||||||
# Clone the specific branch of the new repository
|
# Clone the repository
|
||||||
git clone -b ${GIT_BRANCH:-main} --depth 1 https://$GIT_USERNAME:${GIT_PASSWORD//@/%40}@git.d-popov.com/popov/mwhitnessing.git /tmp/clone || exit 1
|
git clone -b ${GIT_BRANCH:-main} --depth 1 https://$GIT_USERNAME:${GIT_PASSWORD//@/%40}@git.d-popov.com/popov/mwhitnessing.git /tmp/clone || exit 1
|
||||||
# Fetch the latest commit ID and message from the cloned repository
|
|
||||||
GIT_COMMIT_ID=$(git -C /tmp/clone rev-parse HEAD)
|
|
||||||
LAST_COMMIT_MESSAGE=$(git -C /tmp/clone log -1 --pretty=%B)
|
|
||||||
echo "Current Git Commit: $LAST_COMMIT_MESSAGE: $GIT_COMMIT_ID"
|
|
||||||
export GIT_COMMIT_ID
|
|
||||||
|
|
||||||
# Check if the current commit ID matches the latest commit ID
|
# Synchronize all files except package.json and package-lock.json to /app
|
||||||
if [ "$CURRENT_GIT_COMMIT_ID" != "$GIT_COMMIT_ID" ]; then
|
rsync -av --delete --exclude 'package.json' --exclude 'package-lock.json' /tmp/clone/ /app/ || echo "Rsync failed: Issue synchronizing files"
|
||||||
echo "Detected changes in the repository, updating /app..."
|
|
||||||
|
|
||||||
# Use rsync to synchronize the files to /app, including deletion of files not in the source
|
# Determine if package.json or package-lock.json has changed
|
||||||
rsync -av --delete /tmp/clone/ /app/ || echo "Rsync failed: Issue synchronizing files"
|
PACKAGE_CHANGE=0
|
||||||
# Copy .env files
|
if ! cmp -s /tmp/clone/package.json /app/package.json || ! cmp -s /tmp/clone/package-lock.json /app/package-lock.json; then
|
||||||
rsync -av /tmp/clone/.env* /app/ || echo "Rsync failed: Issue copying .env files"
|
PACKAGE_CHANGE=1
|
||||||
# Copy the entrypoint.sh if exists in the new structure
|
fi
|
||||||
[ -f /tmp/clone/entrypoint.sh ] && rsync -av /tmp/clone/entrypoint.sh /app/entrypoint.sh || echo "Rsync failed: Issue copying entrypoint.sh"
|
|
||||||
chmod +x /app/entrypoint.sh
|
|
||||||
|
|
||||||
# Delete and reinstall node_modules if there are changes
|
# If package.json or package-lock.json has changed, copy them and reinstall node_modules
|
||||||
echo "Deleting and reinstalling node_modules..."
|
if [ "$PACKAGE_CHANGE" -eq 1 ]; then
|
||||||
|
echo "Package files have changed. Updating packages..."
|
||||||
|
rsync -av /tmp/clone/package.json /app/package.json || echo "Rsync failed: Issue copying package.json"
|
||||||
|
rsync -av /tmp/clone/package-lock.json /app/package-lock.json || echo "Rsync failed: Issue copying package-lock.json"
|
||||||
rm -rf /app/node_modules
|
rm -rf /app/node_modules
|
||||||
cd /app
|
cd /app
|
||||||
npm install --no-audit --no-fund --no-optional --omit=optional
|
npm install --no-audit --no-fund --no-optional --omit=optional
|
||||||
yes | npx prisma generate
|
yes | npx prisma generate
|
||||||
# Uncomment the next line if database migrations are necessary
|
|
||||||
# npx prisma migrate deploy
|
|
||||||
else
|
else
|
||||||
echo "No changes detected in the repository. Skipping update."
|
echo "Package files have not changed. Skipping package installation."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clean up the temporary clone directory
|
# Clean up
|
||||||
rm -rf /tmp/clone
|
rm -rf /tmp/clone
|
||||||
|
echo "Update process completed."
|
||||||
echo "Done cloning. Current Git Commit ID: $GIT_COMMIT_ID"
|
|
||||||
# Uncomment the following lines for production deployment
|
|
||||||
# npx next build
|
|
||||||
# npx next start
|
|
||||||
else
|
|
||||||
echo "UPDATE_CODE_FROM_GIT is not set to true. Skipping update."
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo "Running the main process"
|
echo "Running the main process"
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
Reference in New Issue
Block a user