diff --git a/backend/.dockerignore b/backend/.dockerignore new file mode 100644 index 0000000..105b916 --- /dev/null +++ b/backend/.dockerignore @@ -0,0 +1,8 @@ +__pycache__/ +*.pyc +.env +*.xlsx +*.csv +*.json +venv/ +.venv/ diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..1a51bad --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,27 @@ +FROM python:3.11-slim + +WORKDIR /app + +# Dependencias del sistema necesarias para pyodbc (SQL Server) y psycopg2 +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc \ + g++ \ + unixodbc \ + unixodbc-dev \ + curl \ + gnupg \ + && curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \ + && curl https://packages.microsoft.com/config/debian/12/prod.list > /etc/apt/sources.list.d/mssql-release.list \ + && apt-get update \ + && ACCEPT_EULA=Y apt-get install -y --no-install-recommends msodbcsql18 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +EXPOSE 8001 + +CMD ["python", "main.py"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ba38631 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,45 @@ +services: + backend: + build: + context: ./backend + dockerfile: Dockerfile + restart: unless-stopped + ports: + - "8001:8001" + environment: + - PG_HOST=${PG_HOST} + - PG_DATABASE=${PG_DATABASE} + - PG_USER=${PG_USER} + - PG_PASSWORD=${PG_PASSWORD} + - PG_PORT=${PG_PORT} + - SQL_SERVER=${SQL_SERVER} + - SQL_DATABASE=${SQL_DATABASE} + - SQL_USERNAME=${SQL_USERNAME} + - SQL_PASSWORD=${SQL_PASSWORD} + - GITHUB_BASE=${GITHUB_BASE} + - SUPABASE_URL=${SUPABASE_URL} + - SUPABASE_KEY=${SUPABASE_KEY} + - SUPABASE_TABLA_LEADS=${SUPABASE_TABLA_LEADS} + - SUPABASE_PAUTA_URL=${SUPABASE_PAUTA_URL} + - SUPABASE_PAUTA_KEY=${SUPABASE_PAUTA_KEY} + - SUPABASE_TABLA_PAUTA=${SUPABASE_TABLA_PAUTA} + - CARTERA_URL=${CARTERA_URL} + - CARTERA_KEY=${CARTERA_KEY} + - SUPABASE_TABLA_CARTERA=${SUPABASE_TABLA_CARTERA} + - SUPABASE_TABLA_ALIAS=${SUPABASE_TABLA_ALIAS} + - SUPABASE_TABLA_CONJUNTO=${SUPABASE_TABLA_CONJUNTO} + - META_CSV_URL=${META_CSV_URL} + - PORT=8001 + - CORS_ORIGINS=${CORS_ORIGINS:-*} + + frontend: + build: + context: ./frontend + dockerfile: Dockerfile + args: + - VITE_API_URL=${VITE_API_URL} + restart: unless-stopped + ports: + - "80:80" + depends_on: + - backend diff --git a/frontend/.dockerignore b/frontend/.dockerignore new file mode 100644 index 0000000..d98184b --- /dev/null +++ b/frontend/.dockerignore @@ -0,0 +1,4 @@ +node_modules/ +dist/ +.vite/ +.env diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..9d1afef --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,22 @@ +# --- Etapa 1: build de la app React/Vite --- +FROM node:20-alpine AS build +WORKDIR /app + +COPY package*.json ./ +RUN npm install + +COPY . . + +# VITE_API_URL debe pasarse como build-arg / env en el momento del build, +# ya que Vite la "quema" dentro del bundle estatico. +ARG VITE_API_URL +ENV VITE_API_URL=$VITE_API_URL + +RUN npm run build + +# --- Etapa 2: servir los archivos estaticos con nginx --- +FROM nginx:alpine +COPY --from=build /app/dist /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 diff --git a/frontend/nginx.conf b/frontend/nginx.conf new file mode 100644 index 0000000..53e7d09 --- /dev/null +++ b/frontend/nginx.conf @@ -0,0 +1,14 @@ +server { + listen 80; + server_name _; + root /usr/share/nginx/html; + index index.html; + + # Soporte para rutas de SPA (React Router / navegacion interna) + location / { + try_files $uri $uri/ /index.html; + } + + gzip on; + gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; +}