forked from freeleaps/freeleaps-pub
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9fd0b985e3 | |||
| 689c1cece1 | |||
|
|
f584e5c440 | ||
| 844cc2b34a | |||
|
|
5fcdde1ce7 |
@ -640,6 +640,38 @@ init_compile_env() {
|
|||||||
|
|
||||||
# Update for export environments []
|
# Update for export environments []
|
||||||
docker exec -i "$DEVBOX_NAME" bash <<EOF
|
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..."
|
echo "[INIT] \$(date '+%Y-%m-%d %H:%M:%S') Starting DevBox initialization..."
|
||||||
|
|
||||||
# Export environment variables
|
# Export environment variables
|
||||||
@ -814,14 +846,6 @@ if true ; then
|
|||||||
--link-workspace-packages false \\
|
--link-workspace-packages false \\
|
||||||
--store-dir /home/tmp/.pnpm-store
|
--store-dir /home/tmp/.pnpm-store
|
||||||
|
|
||||||
# Fix FormData issue for Node.js environment
|
|
||||||
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Installing form-data for Node.js compatibility..."
|
|
||||||
pnpm add form-data@^4.0.0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 4️⃣ Build the frontend
|
# 4️⃣ Build the frontend
|
||||||
pnpm run build
|
pnpm run build
|
||||||
|
|
||||||
@ -996,7 +1020,7 @@ compile_backend_service() {
|
|||||||
# Check if it's the first time by verifying if the backend dependencies have been installed
|
# Check if it's the first time by verifying if the backend dependencies have been installed
|
||||||
if [ ! -f "/home/devbox/.backend_deps_installed" ]; then
|
if [ ! -f "/home/devbox/.backend_deps_installed" ]; then
|
||||||
echo "[BACKEND] \$(date '+%Y-%m-%d %H:%M:%S') Install backend dependencies..."
|
echo "[BACKEND] \$(date '+%Y-%m-%d %H:%M:%S') Install backend dependencies..."
|
||||||
pip install -r /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
pip install --no-cache-dir -r /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
||||||
if ! pip show async_timeout; then
|
if ! pip show async_timeout; then
|
||||||
echo "[BACKEND] \$(date '+%Y-%m-%d %H:%M:%S') async_timeout is missing. Installing..."
|
echo "[BACKEND] \$(date '+%Y-%m-%d %H:%M:%S') async_timeout is missing. Installing..."
|
||||||
pip install async_timeout
|
pip install async_timeout
|
||||||
@ -1042,7 +1066,7 @@ compile_backend_service() {
|
|||||||
|
|
||||||
if [ \$IS_NEW_REQ_ADDED -eq 1 ]; then
|
if [ \$IS_NEW_REQ_ADDED -eq 1 ]; then
|
||||||
echo "[BACKEND] \$(date '+%Y-%m-%d %H:%M:%S') Reinstalling dependencies..."
|
echo "[BACKEND] \$(date '+%Y-%m-%d %H:%M:%S') Reinstalling dependencies..."
|
||||||
pip install -r /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
pip install --no-cache-dir -r /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
||||||
fi
|
fi
|
||||||
# Undo update for /home/devbox/freeleaps/apps/requirements.txt
|
# Undo update for /home/devbox/freeleaps/apps/requirements.txt
|
||||||
rm /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
rm /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
||||||
@ -1056,7 +1080,7 @@ compile_backend_service() {
|
|||||||
# Check if all dependencies are installed, if not, install them
|
# Check if all dependencies are installed, if not, install them
|
||||||
if ! pip check; then
|
if ! pip check; then
|
||||||
echo "[BACKEND] \$(date '+%Y-%m-%d %H:%M:%S') Some dependencies are missing. Reinstalling..."
|
echo "[BACKEND] \$(date '+%Y-%m-%d %H:%M:%S') Some dependencies are missing. Reinstalling..."
|
||||||
pip install -r /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
pip install --no-cache-dir -r /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# pip install async_timeout if not installed
|
# pip install async_timeout if not installed
|
||||||
@ -1102,7 +1126,7 @@ compile_backend_service() {
|
|||||||
|
|
||||||
if [ \$IS_NEW_REQ_ADDED -eq 1 ]; then
|
if [ \$IS_NEW_REQ_ADDED -eq 1 ]; then
|
||||||
echo "[BACKEND] \$(date '+%Y-%m-%d %H:%M:%S') Reinstalling dependencies..."
|
echo "[BACKEND] \$(date '+%Y-%m-%d %H:%M:%S') Reinstalling dependencies..."
|
||||||
pip install -r /home/devbox/freeleaps/apps/requirements.txt
|
pip install --no-cache-dir -r /home/devbox/freeleaps/apps/requirements.txt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Undo update for /home/devbox/freeleaps/apps/requirements.txt
|
# Undo update for /home/devbox/freeleaps/apps/requirements.txt
|
||||||
@ -1256,12 +1280,26 @@ compile_frontend_service() {
|
|||||||
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') USE_LOCAL_COMPONENT_VAL: \$USE_LOCAL_COMPONENT_VAL"
|
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') USE_LOCAL_COMPONENT_VAL: \$USE_LOCAL_COMPONENT_VAL"
|
||||||
if [[ "\$USE_LOCAL_COMPONENT_VAL" == "true" ]]; then
|
if [[ "\$USE_LOCAL_COMPONENT_VAL" == "true" ]]; then
|
||||||
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Use local component dev environment."
|
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Use local component dev environment."
|
||||||
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
|
# Add additional environment variables to .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
|
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
|
||||||
else
|
else
|
||||||
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Use online component dev environment."
|
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Use online component dev environment."
|
||||||
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
|
# Add additional environment variables to .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
|
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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pushd /home/devbox/freeleaps > /dev/null
|
pushd /home/devbox/freeleaps > /dev/null
|
||||||
@ -1345,12 +1383,6 @@ compile_frontend_service() {
|
|||||||
|
|
||||||
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Starting frontend compilation and startup..."
|
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Starting frontend compilation and startup..."
|
||||||
|
|
||||||
# Set environment variables to fix FormData issue
|
|
||||||
export NODE_ENV=development
|
|
||||||
export NODE_OPTIONS="--experimental-global-webcrypto"
|
|
||||||
export VITE_NODE_OPTIONS="--experimental-global-webcrypto"
|
|
||||||
export VITE_SSR=false
|
|
||||||
|
|
||||||
# Start the frontend service (pnpm run dev starts both Vue and Nuxt)
|
# Start the frontend service (pnpm run dev starts both Vue and Nuxt)
|
||||||
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Starting frontend applications (Vue & Nuxt) via pnpm run dev..."
|
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Starting frontend applications (Vue & Nuxt) via pnpm run dev..."
|
||||||
# make sure the output of pnpm run dev is redirected to the log file
|
# make sure the output of pnpm run dev is redirected to the log file
|
||||||
@ -1362,7 +1394,7 @@ compile_frontend_service() {
|
|||||||
|
|
||||||
# Check the health of the frontend services (check Nginx endpoint after starting it)
|
# Check the health of the frontend services (check Nginx endpoint after starting it)
|
||||||
# Health check now needs to wait for Nginx to be up and proxying correctly
|
# Health check now needs to wait for Nginx to be up and proxying correctly
|
||||||
MAX_ATTEMPTS=30
|
MAX_ATTEMPTS=25
|
||||||
ATTEMPT=0
|
ATTEMPT=0
|
||||||
APPS_READY=false
|
APPS_READY=false
|
||||||
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Waiting for frontend applications to become ready..."
|
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Waiting for frontend applications to become ready..."
|
||||||
@ -1372,36 +1404,20 @@ compile_frontend_service() {
|
|||||||
NUXT_PORT=3001
|
NUXT_PORT=3001
|
||||||
VUE_READY=false
|
VUE_READY=false
|
||||||
NUXT_READY=false
|
NUXT_READY=false
|
||||||
|
|
||||||
# Check if processes are running
|
|
||||||
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Checking if frontend processes are running..."
|
|
||||||
if ps -p \$PNPM_PID > /dev/null; then
|
|
||||||
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') pnpm process (PID: \$PNPM_PID) is running."
|
|
||||||
else
|
|
||||||
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') [WARNING] pnpm process (PID: \$PNPM_PID) is not running."
|
|
||||||
fi
|
|
||||||
|
|
||||||
while [ \$ATTEMPT -lt \$MAX_ATTEMPTS ]; do
|
while [ \$ATTEMPT -lt \$MAX_ATTEMPTS ]; do
|
||||||
# check the Vue port
|
# check the Vue port
|
||||||
if ! \$VUE_READY && curl --output /dev/null --silent --head --fail http://localhost:\${VUE_PORT}; then
|
if ! \$VUE_READY && curl --output /dev/null --silent --head --fail http://localhost:\${VUE_PORT}; then
|
||||||
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Vue app (port \${VUE_PORT}) seems ready."
|
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Vue app (port \${VUE_PORT}) seems ready."
|
||||||
VUE_READY=true
|
VUE_READY=true
|
||||||
fi
|
fi
|
||||||
# check the Nuxt port - try both /home/ and root path
|
# check the Nuxt port
|
||||||
if ! \$NUXT_READY; then
|
if ! \$NUXT_READY && curl --output /dev/null --silent --head --fail http://localhost:\${NUXT_PORT}/home/; then
|
||||||
if curl --output /dev/null --silent --head --fail http://localhost:\${NUXT_PORT}/home/; then
|
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Nuxt app (port \${NUXT_PORT}) seems ready."
|
||||||
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Nuxt app (port \${NUXT_PORT}) seems ready."
|
NUXT_READY=true
|
||||||
NUXT_READY=true
|
|
||||||
elif curl --output /dev/null --silent --head --fail http://localhost:\${NUXT_PORT}/; then
|
|
||||||
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Nuxt app (port \${NUXT_PORT}) seems ready (root path)."
|
|
||||||
NUXT_READY=true
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If Vue is ready but Nuxt is not, we can proceed with just Vue
|
if \$VUE_READY && \$NUXT_READY; then
|
||||||
if \$VUE_READY; then
|
|
||||||
APPS_READY=true
|
APPS_READY=true
|
||||||
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Vue app is ready. Proceeding with Vue only."
|
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -3598,7 +3614,9 @@ devbox_init_parse_requirements() {
|
|||||||
add_arg '--devbox-image-name' "devbox_v1"
|
add_arg '--devbox-image-name' "devbox_v1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$(get_arg '--devbox-image-tag')" ]; then
|
if [ "$current_arch" = "amd64" ]; then
|
||||||
|
add_arg '--devbox-image-tag' "devbox_local_amd64"
|
||||||
|
else
|
||||||
add_arg '--devbox-image-tag' "devbox_local"
|
add_arg '--devbox-image-tag' "devbox_local"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@ -341,7 +341,7 @@ services:
|
|||||||
- CERT_PATH=/app/certs
|
- CERT_PATH=/app/certs
|
||||||
- EMAIL_FROM=freeleaps@freeleaps.com
|
- EMAIL_FROM=freeleaps@freeleaps.com
|
||||||
- MONGODB_NAME=freeleaps2
|
- MONGODB_NAME=freeleaps2
|
||||||
- MONGODB_URI=mongodb+srv://jetli:8IHKx6dZK8BfugGp@freeleaps2.hanbj.mongodb.net/
|
- MONGODB_URI=mongodb://freeleaps2-mongodb:27017/
|
||||||
- SITE_URL_ROOT=http://localhost
|
- SITE_URL_ROOT=http://localhost
|
||||||
- JWT_SECRET_KEY=8f87ca8c3c9c3df09a9c78e0adb0927855568f6072d9efc892534aee35f5867b
|
- JWT_SECRET_KEY=8f87ca8c3c9c3df09a9c78e0adb0927855568f6072d9efc892534aee35f5867b
|
||||||
- JWT_ALGORITHM=HS256
|
- JWT_ALGORITHM=HS256
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user