1 Commits

Author SHA1 Message Date
e93944cb9c remo more files from images 2026-02-14 23:19:10 +00:00
3 changed files with 173 additions and 186 deletions

View File

@@ -11,3 +11,7 @@ build
data/output data/output
*.zip *.zip
.DS_Store .DS_Store
Dockerfile
docker-compose.yml
.env
tests

View File

@@ -17,28 +17,32 @@ services:
networks: networks:
- beyond-net - beyond-net
XXXfrontend: frontend:
build: build:
context: ./frontend context: ./frontend
args: args:
# el front compilar con este BASE_URL -> /api # el front compilará con este BASE_URL -> /api
VITE_API_BASE_URL: /api VITE_API_BASE_URL: /api
container_name: beyond-frontend container_name: beyond-frontend
expose: expose:
- "4173" - "4173"
networks: networks:
- beyond-net - beyond-net
- frontend
labels: nginx:
- "traefik.enable=true" image: nginx:1.27-alpine
- "traefik.http.routers.XXX-server.rule=Host(`DDD`)" container_name: beyond-nginx
- "traefik.http.routers.XXX-server.entrypoints=websecure"
- "traefik.http.routers.XXX-server.tls=true"
- "traefik.http.routers.XXX-server.tls.certresolver=doresolv"
- "traefik.http.routers.XXX-server.service=XXXfrontend"
- "traefik.http.services.XXXfrontend.loadBalancer.server.port=4173"
depends_on: depends_on:
- backend - backend
- frontend
ports:
- "80:80"
- "443:443"
volumes:
- /etc/letsencrypt:/etc/letsencrypt:ro
- ./nginx/conf.d:/etc/nginx/conf.d:ro
networks:
- beyond-net
volumes: volumes:
cache-data: cache-data:
@@ -47,5 +51,3 @@ volumes:
networks: networks:
beyond-net: beyond-net:
driver: bridge driver: bridge
frontend:
external: true

View File

@@ -6,7 +6,7 @@ set -euo pipefail
############################################### ###############################################
# TODO: pon aquí la URL real de tu repo (sin credenciales) # TODO: pon aquí la URL real de tu repo (sin credenciales)
REPO_URL_DEFAULT="https://github.com/igferne/Beyond-Diagnosis.git" REPO_URL_DEFAULT="https://github.com/igferne/Beyond-Diagnosis.git"
INSTALL_BASE="/home/garbelo/" INSTALL_DIR="/opt/beyonddiagnosis"
############################################### ###############################################
# UTILIDADES # UTILIDADES
@@ -37,8 +37,7 @@ if [ -z "$DOMAIN" ]; then
echo "El dominio no puede estar vacío." echo "El dominio no puede estar vacío."
exit 1 exit 1
fi fi
SUBDOMAIN="$DOMAIN%%.*"
INSTALL_DIR=$INSTALL_BASE"/"$SUBDOMAIN
read -rp "Email para Let's Encrypt (avisos de renovación): " EMAIL read -rp "Email para Let's Encrypt (avisos de renovación): " EMAIL
if [ -z "$EMAIL" ]; then if [ -z "$EMAIL" ]; then
echo "El email no puede estar vacío." echo "El email no puede estar vacío."
@@ -67,32 +66,30 @@ read -rp "¿El repositorio es PRIVADO en GitHub y necesitas token? [s/N]: " IS_P
IS_PRIVATE=${IS_PRIVATE:-N} IS_PRIVATE=${IS_PRIVATE:-N}
GIT_CLONE_URL="$REPO_URL" GIT_CLONE_URL="$REPO_URL"
#if [[ "$IS_PRIVATE" =~ ^[sS]$ ]]; then if [[ "$IS_PRIVATE" =~ ^[sS]$ ]]; then
# echo "Introduce un Personal Access Token (PAT) de GitHub con permiso de lectura del repo." echo "Introduce un Personal Access Token (PAT) de GitHub con permiso de lectura del repo."
# read -rsp "GitHub PAT: " GITHUB_TOKEN read -rsp "GitHub PAT: " GITHUB_TOKEN
# echo echo
# if [ -z "$GITHUB_TOKEN" ]; then if [ -z "$GITHUB_TOKEN" ]; then
# echo "El token no puede estar vacío si el repo es privado." echo "El token no puede estar vacío si el repo es privado."
# exit 1 exit 1
# fi fi
#
# # Construimos una URL del tipo: https://TOKEN@github.com/usuario/repo.git # Construimos una URL del tipo: https://TOKEN@github.com/usuario/repo.git
# if [[ "$REPO_URL" =~ ^https:// ]]; then if [[ "$REPO_URL" =~ ^https:// ]]; then
# GIT_CLONE_URL="https://${GITHUB_TOKEN}@${REPO_URL#https://}" GIT_CLONE_URL="https://${GITHUB_TOKEN}@${REPO_URL#https://}"
# else else
# echo "La URL del repositorio debe empezar por https:// para usar el token." echo "La URL del repositorio debe empezar por https:// para usar el token."
# exit 1 exit 1
# fi fi
#fi fi
#
echo echo
echo "Resumen de configuración:" echo "Resumen de configuración:"
echo " Dominio: $DOMAIN" echo " Dominio: $DOMAIN"
echo " Email Let'sEnc: $EMAIL" echo " Email Let'sEnc: $EMAIL"
echo " Usuario API: $API_USER" echo " Usuario API: $API_USER"
echo " Repo (visible): $REPO_URL" echo " Repo (visible): $REPO_URL"
echo " Path del despliegue: $INSTALL_DIR"
if [[ "$IS_PRIVATE" =~ ^[sS]$ ]]; then if [[ "$IS_PRIVATE" =~ ^[sS]$ ]]; then
echo " Repo privado: Sí (se usará un PAT sólo para el clon inicial)" echo " Repo privado: Sí (se usará un PAT sólo para el clon inicial)"
else else
@@ -110,56 +107,56 @@ fi
############################################### ###############################################
# 2. INSTALAR DOCKER + DOCKER COMPOSE + CERTBOT # 2. INSTALAR DOCKER + DOCKER COMPOSE + CERTBOT
############################################### ###############################################
#step "Instalando Docker, docker compose plugin y certbot" step "Instalando Docker, docker compose plugin y certbot"
#
#apt-get update -y apt-get update -y
#
## Dependencias para repositorio Docker # Dependencias para repositorio Docker
#apt-get install -y \ apt-get install -y \
# ca-certificates \ ca-certificates \
# curl \ curl \
# gnupg \ gnupg \
# lsb-release lsb-release
#
## Clave GPG de Docker # Clave GPG de Docker
#if [ ! -f /etc/apt/keyrings/docker.gpg ]; then if [ ! -f /etc/apt/keyrings/docker.gpg ]; then
# install -m 0755 -d /etc/apt/keyrings install -m 0755 -d /etc/apt/keyrings
# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
# gpg --dearmor -o /etc/apt/keyrings/docker.gpg gpg --dearmor -o /etc/apt/keyrings/docker.gpg
#fi fi
#
## Repo Docker estable # Repo Docker estable
#if [ ! -f /etc/apt/sources.list.d/docker.list ]; then if [ ! -f /etc/apt/sources.list.d/docker.list ]; then
# echo \ echo \
# "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
# $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
# tee /etc/apt/sources.list.d/docker.list > /dev/null tee /etc/apt/sources.list.d/docker.list > /dev/null
#fi fi
#
#apt-get update -y apt-get update -y
#
#apt-get install -y \ apt-get install -y \
# docker-ce \ docker-ce \
# docker-ce-cli \ docker-ce-cli \
# containerd.io \ containerd.io \
# docker-buildx-plugin \ docker-buildx-plugin \
# docker-compose-plugin \ docker-compose-plugin \
# git \ git \
# certbot certbot
#
#systemctl enable docker systemctl enable docker
#systemctl start docker systemctl start docker
#
## Abrimos puertos en ufw si está activo # Abrimos puertos en ufw si está activo
#if command -v ufw >/dev/null 2>&1; then if command -v ufw >/dev/null 2>&1; then
# if ufw status | grep -q "Status: active"; then if ufw status | grep -q "Status: active"; then
# step "Configurando firewall (ufw) para permitir 80 y 443" step "Configurando firewall (ufw) para permitir 80 y 443"
# ufw allow 80/tcp || true ufw allow 80/tcp || true
# ufw allow 443/tcp || true ufw allow 443/tcp || true
# fi fi
#fi fi
#
################################################ ###############################################
# 3. CLONAR / ACTUALIZAR REPO # 3. CLONAR / ACTUALIZAR REPO
############################################### ###############################################
step "Descargando/actualizando el repositorio en $INSTALL_DIR" step "Descargando/actualizando el repositorio en $INSTALL_DIR"
@@ -192,110 +189,94 @@ else
sed -i "s/BASIC_AUTH_PASSWORD:.*/BASIC_AUTH_PASSWORD: \"$API_PASS\"/" docker-compose.yml sed -i "s/BASIC_AUTH_PASSWORD:.*/BASIC_AUTH_PASSWORD: \"$API_PASS\"/" docker-compose.yml
fi fi
if ! grep -q "XXX" docker-compose.yml; then
echo "⚠ No encuentro XXX en docker-compose.yml. Revisa el archivo a mano."
else
sed -i "s/XXX/\"$SUBDOMAIN\"/" docker-compose.yml
fi
if $DOMAIN==$SUBDOMAIN; then
DOMAIN=$DOMAIN".analytics.beyondcx.org"
fi
if ! grep -q "DDD" docker-compose.yml; then
echo "⚠ No encuentro XXX en docker-compose.yml. Revisa el archivo a mano."
else
sed -i "s/DDD/\"$DOMAIN\"/" docker-compose.yml
fi
# Aseguramos que nginx exponga también 443 # Aseguramos que nginx exponga también 443
#if grep -q 'ports:' docker-compose.yml && grep -q 'nginx:' docker-compose.yml; then if grep -q 'ports:' docker-compose.yml && grep -q 'nginx:' docker-compose.yml; then
# if ! grep -q '443:443' docker-compose.yml; then if ! grep -q '443:443' docker-compose.yml; then
# sed -i '/- "80:80"/a\ - "443:443"' docker-compose.yml || true sed -i '/- "80:80"/a\ - "443:443"' docker-compose.yml || true
# fi fi
#fi fi
#
## Aseguramos que montamos /etc/letsencrypt dentro del contenedor de nginx # Aseguramos que montamos /etc/letsencrypt dentro del contenedor de nginx
#if ! grep -q '/etc/letsencrypt:/etc/letsencrypt:ro' docker-compose.yml; then if ! grep -q '/etc/letsencrypt:/etc/letsencrypt:ro' docker-compose.yml; then
# sed -i '/nginx:/,/networks:/{ sed -i '/nginx:/,/networks:/{
# /volumes:/a\ - /etc/letsencrypt:/etc/letsencrypt:ro /volumes:/a\ - /etc/letsencrypt:/etc/letsencrypt:ro
# }' docker-compose.yml || true }' docker-compose.yml || true
#fi fi
#
############################################### ###############################################
# 5. OBTENER CERTIFICADO LET'S ENCRYPT # 5. OBTENER CERTIFICADO LET'S ENCRYPT
############################################### ###############################################
#step "Obteniendo certificado SSL de Lets Encrypt para $DOMAIN" step "Obteniendo certificado SSL de Lets Encrypt para $DOMAIN"
#
#if [ -f "/etc/letsencrypt/live/$DOMAIN/fullchain.pem" ]; then if [ -f "/etc/letsencrypt/live/$DOMAIN/fullchain.pem" ]; then
# echo "Certificado ya existe, saltando paso de emisión." echo "Certificado ya existe, saltando paso de emisión."
#else else
# # Asegurarnos de que no hay nada escuchando en 80/443 # Asegurarnos de que no hay nada escuchando en 80/443
# systemctl stop nginx || true systemctl stop nginx || true
#
# certbot certonly \ certbot certonly \
# --standalone \ --standalone \
# --non-interactive \ --non-interactive \
# --agree-tos \ --agree-tos \
# -m "$EMAIL" \ -m "$EMAIL" \
# -d "$DOMAIN" -d "$DOMAIN"
#
# echo "Certificado emitido en /etc/letsencrypt/live/$DOMAIN/" echo "Certificado emitido en /etc/letsencrypt/live/$DOMAIN/"
#fi fi
#
################################################ ###############################################
## 6. CONFIGURAR NGINX DENTRO DEL REPO # 6. CONFIGURAR NGINX DENTRO DEL REPO
################################################ ###############################################
#step "Generando configuración nginx con SSL" step "Generando configuración nginx con SSL"
#
#mkdir -p nginx/conf.d mkdir -p nginx/conf.d
#
#cat > nginx/conf.d/beyond.conf <<EOF cat > nginx/conf.d/beyond.conf <<EOF
#server { server {
# listen 80; listen 80;
# server_name $DOMAIN; server_name $DOMAIN;
# return 301 https://\$host\$request_uri; return 301 https://\$host\$request_uri;
# client_max_body_size 1024M; client_max_body_size 1024M;
#} }
#
#server { server {
# listen 443 ssl; listen 443 ssl;
# server_name $DOMAIN; server_name $DOMAIN;
#
# client_max_body_size 1024M; client_max_body_size 1024M;
#
# ssl_certificate /etc/letsencrypt/live/$DOMAIN/fullchain.pem; ssl_certificate /etc/letsencrypt/live/$DOMAIN/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/$DOMAIN/privkey.pem; ssl_certificate_key /etc/letsencrypt/live/$DOMAIN/privkey.pem;
# ssl_protocols TLSv1.2 TLSv1.3; ssl_protocols TLSv1.2 TLSv1.3;
# ssl_ciphers HIGH:!aNULL:!MD5; ssl_ciphers HIGH:!aNULL:!MD5;
#
# # FRONTEND (React) # FRONTEND (React)
# location / { location / {
# proxy_pass http://frontend:4173/; proxy_pass http://frontend:4173/;
# proxy_http_version 1.1; proxy_http_version 1.1;
# proxy_set_header Host \$host; proxy_set_header Host \$host;
# proxy_set_header X-Real-IP \$remote_addr; proxy_set_header X-Real-IP \$remote_addr;
# proxy_set_header Upgrade \$http_upgrade; proxy_set_header Upgrade \$http_upgrade;
# proxy_set_header Connection "upgrade"; proxy_set_header Connection "upgrade";
# } }
#
# # BACKEND (FastAPI) # BACKEND (FastAPI)
# location /api/ { location /api/ {
# proxy_pass http://backend:8000/; proxy_pass http://backend:8000/;
# proxy_http_version 1.1; proxy_http_version 1.1;
# proxy_set_header Host \$host; proxy_set_header Host \$host;
# proxy_set_header X-Real-IP \$remote_addr; proxy_set_header X-Real-IP \$remote_addr;
# proxy_set_header Upgrade \$http_upgrade; proxy_set_header Upgrade \$http_upgrade;
# proxy_set_header Connection "upgrade"; proxy_set_header Connection "upgrade";
#
# proxy_connect_timeout 60s; proxy_connect_timeout 60s;
# proxy_send_timeout 600s; proxy_send_timeout 600s;
# proxy_read_timeout 600s; proxy_read_timeout 600s;
# send_timeout 600s; send_timeout 600s;
# } }
#} }
#EOF EOF
#
############################################### ###############################################
# 7. BUILD Y ARRANQUE DE CONTENEDORES # 7. BUILD Y ARRANQUE DE CONTENEDORES
############################################### ###############################################