ca6d370585
This removes the incorrect /deckofcars prefix, aligns CI/build defaults with the real public URL, and adds an Apache ProxyPass snippet so the request is routed to the Docker frontend instead of the Sinbad2 site.
64 lines
2.0 KiB
YAML
64 lines
2.0 KiB
YAML
stages:
|
|
- deploy
|
|
|
|
variables:
|
|
APP_NAME: "generadorexamenesllms"
|
|
BACKEND_PORT: "8074"
|
|
FRONTEND_PORT: "8075"
|
|
|
|
deploy_to_sinbad2:
|
|
stage: deploy
|
|
|
|
before_script:
|
|
- eval $(ssh-agent -s)
|
|
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
|
|
- mkdir -p ~/.ssh
|
|
- chmod 700 ~/.ssh
|
|
- ssh-keyscan $SSH_HOST >> ~/.ssh/known_hosts
|
|
|
|
script:
|
|
- echo "Enviando código a Sinbad2..."
|
|
- ssh $REMOTE_USER@$SSH_HOST "mkdir -p ~/deploy_$APP_NAME"
|
|
|
|
- scp -r ./* $REMOTE_USER@$SSH_HOST:~/deploy_$APP_NAME/
|
|
|
|
- echo "Levantando contenedores con Docker Compose..."
|
|
- |
|
|
ssh "$REMOTE_USER@$SSH_HOST" <<EOF
|
|
set -e
|
|
cd ~/deploy_$APP_NAME
|
|
echo "Comprobando puertos en uso..."
|
|
docker ps --format '{{.ID}} {{.Ports}}' | grep -E "0.0.0.0:$FRONTEND_PORT->|0.0.0.0:$BACKEND_PORT->" || true
|
|
|
|
CONFLICT_FRONT=\$(docker ps -q --filter publish=$FRONTEND_PORT)
|
|
if [ -n "\$CONFLICT_FRONT" ]; then
|
|
echo "Liberando puerto frontend $FRONTEND_PORT (contenedores: \$CONFLICT_FRONT)"
|
|
docker stop \$CONFLICT_FRONT
|
|
docker rm \$CONFLICT_FRONT
|
|
fi
|
|
|
|
CONFLICT_BACK=\$(docker ps -q --filter publish=$BACKEND_PORT)
|
|
if [ -n "\$CONFLICT_BACK" ]; then
|
|
echo "Liberando puerto backend $BACKEND_PORT (contenedores: \$CONFLICT_BACK)"
|
|
docker stop \$CONFLICT_BACK
|
|
docker rm \$CONFLICT_BACK
|
|
fi
|
|
|
|
export BACKEND_PORT=$BACKEND_PORT
|
|
export FRONTEND_PORT=$FRONTEND_PORT
|
|
export ALLOWED_ORIGINS="https://sinbad2.ujaen.es,http://sinbad2.ujaen.es,http://sinbad2.ujaen.es:$FRONTEND_PORT"
|
|
export VITE_APP_BASE_PATH="/generadorexamenesllm/"
|
|
export VITE_API_URL=""
|
|
|
|
docker compose down --remove-orphans
|
|
docker compose build --no-cache frontend backend
|
|
docker compose up -d
|
|
EOF
|
|
|
|
- echo "Despliegue completado."
|
|
- echo "Backend -> http://sinbad2.ujaen.es:$BACKEND_PORT"
|
|
- echo "Frontend -> http://sinbad2.ujaen.es:$FRONTEND_PORT"
|
|
- echo "Public URL -> https://sinbad2.ujaen.es/generadorexamenesllm/"
|
|
|
|
only:
|
|
- branches |