JPSolutions commited on
Commit
89e0fae
·
verified ·
1 Parent(s): 1edf18e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +27 -26
Dockerfile CHANGED
@@ -53,7 +53,7 @@ RUN git clone https://github.com/rbenv/ruby-build.git /tmp/ruby-build && \
53
  /tmp/ruby-build/bin/ruby-build 3.4.4 /usr/local && \
54
  rm -rf /tmp/ruby-build
55
 
56
- # Instalar Bundler y Rails con el nuevo Ruby 3.4.4
57
  RUN gem install bundler rails
58
  RUN pip3 install --no-cache-dir uvicorn fastapi
59
 
@@ -68,32 +68,33 @@ COPY --from=frontend-builder /build/dist_output /var/www/html/
68
  # Pre-instalar gemas de Ruby en todas las carpetas con Gemfile
69
  RUN find /app -name "Gemfile" -not -path "*/vendor/*" -execdir bundle install \;
70
 
71
- # Configurar Nginx para el puerto 7860 de Hugging Face
72
- RUN echo 'server { listen 7860; server_name _; root /var/www/html; index index.html; location / { try_files $uri $uri/ /index.html; } }' > /etc/nginx/sites-available/default
73
-
74
  COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
75
 
76
- # Parche de seguridad usando Python3 para corregir todas las migraciones incompatibles
77
- RUN python3 -c ' \
78
- import glob; \
79
- for filepath in glob.glob("/app/**/db/migrate/*.rb", recursive=True): \
80
- with open(filepath, "r") as f: \
81
- content = f.read(); \
82
- if "add_facebook_comment_config_to_agent_bot_inboxes" in filepath: \
83
- content = content.replace(":uuid", ":bigint"); \
84
- if "create_facebook_comment_moderations" in filepath: \
85
- content = content.replace(":uuid", ":integer").replace("type: :uuid", "type: :integer"); \
86
- if "20250819224900_init_schema.rb" in filepath: \
87
- lines = []; \
88
- for line in content.splitlines(): \
89
- if "add_index :users" in line and not any(k in line for k in [":email", ":reset_password_token"]): \
90
- lines.append("# " + line); \
91
- else: \
92
- lines.append(line); \
93
- content = "\n".join(lines); \
94
- with open(filepath, "w") as f: \
95
- f.write(content); \
96
- '
 
 
97
 
98
  # Entrypoint: ejecuta db:prepare en todos los submódulos de Rails
99
  RUN printf '#!/bin/bash\n\
@@ -104,4 +105,4 @@ exec "$@"\n' > /entrypoint.sh && chmod +x /entrypoint.sh
104
 
105
  EXPOSE 7860
106
  ENTRYPOINT ["/entrypoint.sh"]
107
- CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
 
53
  /tmp/ruby-build/bin/ruby-build 3.4.4 /usr/local && \
54
  rm -rf /tmp/ruby-build
55
 
56
+ # Instalar Bundler y Rails con Ruby 3.4.4
57
  RUN gem install bundler rails
58
  RUN pip3 install --no-cache-dir uvicorn fastapi
59
 
 
68
  # Pre-instalar gemas de Ruby en todas las carpetas con Gemfile
69
  RUN find /app -name "Gemfile" -not -path "*/vendor/*" -execdir bundle install \;
70
 
71
+ # Copiar configuraciones
72
+ COPY nginx.conf /etc/nginx/nginx.conf
 
73
  COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
74
 
75
+ # Parche de migraciones ejecutado de forma limpia mediante un script Python temporal
76
+ RUN printf '%s\n' \
77
+ 'import glob' \
78
+ 'for filepath in glob.glob("/app/**/db/migrate/*.rb", recursive=True):' \
79
+ ' with open(filepath, "r") as f:' \
80
+ ' content = f.read()' \
81
+ ' if "add_facebook_comment_config_to_agent_bot_inboxes" in filepath:' \
82
+ ' content = content.replace(":uuid", ":bigint")' \
83
+ ' if "create_facebook_comment_moderations" in filepath:' \
84
+ ' content = content.replace(":uuid", ":integer").replace("type: :uuid", "type: :integer")' \
85
+ ' if "20250819224900_init_schema.rb" in filepath:' \
86
+ ' lines = []' \
87
+ ' for line in content.splitlines():' \
88
+ ' if "add_index :users" in line and not any(k in line for k in [":email", ":reset_password_token"]):' \
89
+ ' lines.append("# " + line)' \
90
+ ' else:' \
91
+ ' lines.append(line)' \
92
+ ' content = "\n".join(lines)' \
93
+ ' with open(filepath, "w") as f:' \
94
+ ' f.write(content)' \
95
+ > /tmp/patch_migrations.py \
96
+ && python3 /tmp/patch_migrations.py \
97
+ && rm /tmp/patch_migrations.py
98
 
99
  # Entrypoint: ejecuta db:prepare en todos los submódulos de Rails
100
  RUN printf '#!/bin/bash\n\
 
105
 
106
  EXPOSE 7860
107
  ENTRYPOINT ["/entrypoint.sh"]
108
+ CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]