forked from freeleaps/freeleaps-pub
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a26fb6795 |
@ -640,38 +640,6 @@ init_compile_env() {
|
||||
|
||||
# Update for export environments []
|
||||
docker exec -i "$DEVBOX_NAME" bash <<EOF
|
||||
# Detect the network environment
|
||||
echo "[INIT] $(date '+%Y-%m-%d %H:%M:%S') Checking network connectivity..."
|
||||
|
||||
# Check if you can access Google
|
||||
if ping -c 1 -W 5 google.com > /dev/null 2>&1; then
|
||||
echo "[INIT] $(date '+%Y-%m-%d %H:%M:%S') Google is accessible, using default Ubuntu sources"
|
||||
# Use the default Ubuntu source without any modifications
|
||||
echo "[INIT] $(date '+%Y-%m-%d %H:%M:%S') Keeping default Ubuntu sources"
|
||||
else
|
||||
echo "[INIT] $(date '+%Y-%m-%d %H:%M:%S') Google is not accessible, switching to Aliyun mirrors"
|
||||
# Back up the original source list
|
||||
cp /etc/apt/sources.list /etc/apt/sources.list.backup
|
||||
echo "[INIT] $(date '+%Y-%m-%d %H:%M:%S') Backup original sources.list to sources.list.backup"
|
||||
|
||||
# Replace with an Alibaba Cloud mirror source
|
||||
cat > /etc/apt/sources.list << 'SOURCES_EOF'
|
||||
deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
|
||||
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
|
||||
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
|
||||
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
|
||||
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
|
||||
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
|
||||
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
|
||||
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
|
||||
SOURCES_EOF
|
||||
echo "[INIT] $(date '+%Y-%m-%d %H:%M:%S') Successfully replaced with Aliyun mirrors"
|
||||
fi
|
||||
|
||||
# Update package list
|
||||
echo "[INIT] $(date '+%Y-%m-%d %H:%M:%S') Updating package lists..."
|
||||
apt-get update
|
||||
|
||||
echo "[INIT] \$(date '+%Y-%m-%d %H:%M:%S') Starting DevBox initialization..."
|
||||
|
||||
# Export environment variables
|
||||
@ -1020,7 +988,7 @@ compile_backend_service() {
|
||||
# Check if it's the first time by verifying if the backend dependencies have been installed
|
||||
if [ ! -f "/home/devbox/.backend_deps_installed" ]; then
|
||||
echo "[BACKEND] \$(date '+%Y-%m-%d %H:%M:%S') Install backend dependencies..."
|
||||
pip install --no-cache-dir -r /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
||||
pip install -r /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
||||
if ! pip show async_timeout; then
|
||||
echo "[BACKEND] \$(date '+%Y-%m-%d %H:%M:%S') async_timeout is missing. Installing..."
|
||||
pip install async_timeout
|
||||
@ -1066,7 +1034,7 @@ compile_backend_service() {
|
||||
|
||||
if [ \$IS_NEW_REQ_ADDED -eq 1 ]; then
|
||||
echo "[BACKEND] \$(date '+%Y-%m-%d %H:%M:%S') Reinstalling dependencies..."
|
||||
pip install --no-cache-dir -r /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
||||
pip install -r /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
||||
fi
|
||||
# Undo update for /home/devbox/freeleaps/apps/requirements.txt
|
||||
rm /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
||||
@ -1080,7 +1048,7 @@ compile_backend_service() {
|
||||
# Check if all dependencies are installed, if not, install them
|
||||
if ! pip check; then
|
||||
echo "[BACKEND] \$(date '+%Y-%m-%d %H:%M:%S') Some dependencies are missing. Reinstalling..."
|
||||
pip install --no-cache-dir -r /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
||||
pip install -r /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
||||
fi
|
||||
|
||||
# pip install async_timeout if not installed
|
||||
@ -1126,7 +1094,7 @@ compile_backend_service() {
|
||||
|
||||
if [ \$IS_NEW_REQ_ADDED -eq 1 ]; then
|
||||
echo "[BACKEND] \$(date '+%Y-%m-%d %H:%M:%S') Reinstalling dependencies..."
|
||||
pip install --no-cache-dir -r /home/devbox/freeleaps/apps/requirements.txt
|
||||
pip install -r /home/devbox/freeleaps/apps/requirements.txt
|
||||
fi
|
||||
|
||||
# Undo update for /home/devbox/freeleaps/apps/requirements.txt
|
||||
@ -1280,26 +1248,12 @@ compile_frontend_service() {
|
||||
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') USE_LOCAL_COMPONENT_VAL: \$USE_LOCAL_COMPONENT_VAL"
|
||||
if [[ "\$USE_LOCAL_COMPONENT_VAL" == "true" ]]; then
|
||||
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Use local component dev environment."
|
||||
# Add additional environment variables to .env.development
|
||||
echo "VITE_PROXY_API_URL=http://localhost:8002" > /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
echo "VITE_PROXY_WEBSOCKET_URL=ws://localhost:8002" >> /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
echo "VITE_AUTHORIZE_LOGIN_URL=http://localhost:3001" >> /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
echo "VITE_PROXY_API_CHAT_URL=http://chat:8012" >> /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
echo "VITE_PROXY_WEBSOCKET_CHAT_URL=ws://chat:8012" >> /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
echo "VITE_BACKEND_API_URL=http://localhost:8002" >> /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
echo "VITE_WEBSOCKET_URL=ws://localhost:8002" >> /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
echo "VITE_DEV_MODE=true" >> /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
sed -i 's#VITE_PROXY_WEBSOCKET_CHAT_URL=ws://localhost:8012#VITE_PROXY_WEBSOCKET_CHAT_URL=ws://chat:8012#g' /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
sed -i 's#VITE_PROXY_API_CHAT_URL=http://localhost:8012#VITE_PROXY_API_CHAT_URL=http://chat:8012#g' /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
else
|
||||
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Use online component dev environment."
|
||||
# Add additional environment variables to .env.development
|
||||
echo "VITE_PROXY_API_URL=https://freeleaps-alpha.com" > /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
echo "VITE_PROXY_WEBSOCKET_URL=ws://freeleaps-alpha.com" >> /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
echo "VITE_AUTHORIZE_LOGIN_URL=https://authentication.freeleaps-alpha.com" >> /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
echo "VITE_PROXY_API_CHAT_URL=https://freeleaps-alpha.com" >> /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
echo "VITE_PROXY_WEBSOCKET_CHAT_URL=wss://freeleaps-alpha.com" >> /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
echo "VITE_BACKEND_API_URL=https://freeleaps-alpha.com" >> /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
echo "VITE_WEBSOCKET_URL=ws://freeleaps-alpha.com" >> /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
echo "VITE_DEV_MODE=true" >> /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
sed -i 's#VITE_PROXY_WEBSOCKET_CHAT_URL=wss://localhost:8012#VITE_PROXY_WEBSOCKET_CHAT_URL=wss://freeleaps-alpha.com#g' /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
sed -i 's#VITE_PROXY_API_CHAT_URL=http://localhost:8012#VITE_PROXY_API_CHAT_URL=https://freeleaps-alpha.com#g' /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
fi
|
||||
|
||||
pushd /home/devbox/freeleaps > /dev/null
|
||||
@ -2047,13 +2001,14 @@ devbox_init_command() {
|
||||
if [ ! -d "$FREELEAPS_DIR" ]; then
|
||||
pushd "$WORKING_HOME" >/dev/null
|
||||
log_info "Git cloning gitea.freeleaps.mathmast.com/products/freeleaps.git to $FREELEAPS_DIR"
|
||||
git clone --depth 5 $FRONTEND_GIT_URL
|
||||
git clone $FRONTEND_GIT_URL
|
||||
|
||||
# Checkout the specified branch
|
||||
if [[ -n "$GIT_BRANCH" && "$GIT_BRANCH" != "main" ]]; then
|
||||
pushd "$FREELEAPS_DIR" >/dev/null
|
||||
log_info "Checking out branch: $GIT_BRANCH"
|
||||
if ! git checkout $GIT_BRANCH; then
|
||||
log_warn "Please check if the $GIT_BRANCH branch exists locally in the path $FREELEAPS_DIR. If it does not exist, you may attempt to manually pull the latest code."
|
||||
log_warn "Failed to checkout branch $GIT_BRANCH, falling back to main branch"
|
||||
git checkout main
|
||||
fi
|
||||
@ -2073,13 +2028,14 @@ devbox_init_command() {
|
||||
gid=$(id -g)
|
||||
sudo chown -R ${uid}:${gid} "$WORKING_HOME"
|
||||
|
||||
git clone --depth 5 "$FRONTEND_GIT_URL"
|
||||
git clone "$FRONTEND_GIT_URL"
|
||||
|
||||
# Checkout the specified branch
|
||||
if [[ -n "$GIT_BRANCH" && "$GIT_BRANCH" != "main" ]]; then
|
||||
pushd "$FREELEAPS_DIR" >/dev/null
|
||||
log_info "Checking out branch: $GIT_BRANCH"
|
||||
if ! git checkout $GIT_BRANCH; then
|
||||
log_warn "Please check if the $GIT_BRANCH branch exists locally in the path $FREELEAPS_DIR. If it does not exist, you may attempt to manually pull the latest code."
|
||||
log_warn "Failed to checkout branch $GIT_BRANCH, falling back to main branch"
|
||||
git checkout main
|
||||
fi
|
||||
@ -2100,6 +2056,7 @@ devbox_init_command() {
|
||||
elif git checkout -b $GIT_BRANCH origin/$GIT_BRANCH 2>/dev/null; then
|
||||
log_info "Checked out remote branch: $GIT_BRANCH"
|
||||
else
|
||||
log_warn "Please check if the $GIT_BRANCH branch exists locally in the path $FREELEAPS_DIR. If it does not exist, you may attempt to manually pull the latest code."
|
||||
log_warn "Failed to checkout branch $GIT_BRANCH, falling back to main branch"
|
||||
git checkout main
|
||||
fi
|
||||
@ -2130,13 +2087,14 @@ devbox_init_command() {
|
||||
if [ ! -d "$CUSTOM_DIR" ]; then
|
||||
pushd "$WORKING_HOME" >/dev/null
|
||||
log_info "Git cloning custom repository: $ECHO_USE_CUSTOM_REPOSITORY"
|
||||
git clone --depth 5 "$USE_CUSTOM_REPOSITORY"
|
||||
git clone "$USE_CUSTOM_REPOSITORY"
|
||||
|
||||
# Checkout the specified branch
|
||||
if [[ -n "$GIT_BRANCH" && "$GIT_BRANCH" != "main" ]]; then
|
||||
pushd "$CUSTOM_DIR" >/dev/null
|
||||
log_info "Checking out branch: $GIT_BRANCH"
|
||||
if ! git checkout $GIT_BRANCH; then
|
||||
log_warn "Please check if the $GIT_BRANCH branch exists locally in the path $CUSTOM_DIR. If it does not exist, you may attempt to manually pull the latest code."
|
||||
log_warn "Failed to checkout branch $GIT_BRANCH, falling back to main branch"
|
||||
git checkout main
|
||||
fi
|
||||
@ -2156,13 +2114,14 @@ devbox_init_command() {
|
||||
gid=$(id -g)
|
||||
sudo chown -R ${uid}:${gid} "$WORKING_HOME"
|
||||
|
||||
git clone --depth 5 "$USE_CUSTOM_REPOSITORY"
|
||||
git clone "$USE_CUSTOM_REPOSITORY"
|
||||
|
||||
# Checkout the specified branch
|
||||
if [[ -n "$GIT_BRANCH" && "$GIT_BRANCH" != "main" ]]; then
|
||||
pushd "$CUSTOM_DIR" >/dev/null
|
||||
log_info "Checking out branch: $GIT_BRANCH"
|
||||
if ! git checkout $GIT_BRANCH; then
|
||||
log_warn "Please check if the $GIT_BRANCH branch exists locally in the path $CUSTOM_DIR. If it does not exist, you may attempt to manually pull the latest code."
|
||||
log_warn "Failed to checkout branch $GIT_BRANCH, falling back to main branch"
|
||||
git checkout main
|
||||
fi
|
||||
@ -2176,6 +2135,7 @@ devbox_init_command() {
|
||||
if [[ -n "$GIT_BRANCH" ]]; then
|
||||
log_info "Checking out branch: $GIT_BRANCH"
|
||||
if ! git checkout $GIT_BRANCH; then
|
||||
log_warn "Please check if the $GIT_BRANCH branch exists locally in the path $CUSTOM_DIR. If it does not exist, you may attempt to manually pull the latest code."
|
||||
log_warn "Failed to checkout branch $GIT_BRANCH, falling back to main branch"
|
||||
git checkout main
|
||||
else
|
||||
@ -3614,9 +3574,7 @@ devbox_init_parse_requirements() {
|
||||
add_arg '--devbox-image-name' "devbox_v1"
|
||||
fi
|
||||
|
||||
if [ "$current_arch" = "amd64" ]; then
|
||||
add_arg '--devbox-image-tag' "devbox_local_amd64"
|
||||
else
|
||||
if [ -z "$(get_arg '--devbox-image-tag')" ]; then
|
||||
add_arg '--devbox-image-tag' "devbox_local"
|
||||
fi
|
||||
|
||||
|
||||
@ -341,7 +341,7 @@ services:
|
||||
- CERT_PATH=/app/certs
|
||||
- EMAIL_FROM=freeleaps@freeleaps.com
|
||||
- MONGODB_NAME=freeleaps2
|
||||
- MONGODB_URI=mongodb://freeleaps2-mongodb:27017/
|
||||
- MONGODB_URI=mongodb+srv://jetli:8IHKx6dZK8BfugGp@freeleaps2.hanbj.mongodb.net/
|
||||
- SITE_URL_ROOT=http://localhost
|
||||
- JWT_SECRET_KEY=8f87ca8c3c9c3df09a9c78e0adb0927855568f6072d9efc892534aee35f5867b
|
||||
- JWT_ALGORITHM=HS256
|
||||
|
||||
Loading…
Reference in New Issue
Block a user