From 3d487e427933449a9d604ab510afbca4cc3cab4f Mon Sep 17 00:00:00 2001 From: Manuel Cillero Date: Sun, 22 Jun 2025 01:16:32 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Integra=20scripts=20y=20c=C3=B3d?= =?UTF-8?q?igo=20para=20docker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 59 +++++++++++++++ config/ckeditor.yml | 143 +++++++++++++++++++++++++++++++++++++ config/database.yml.sample | 7 ++ config/secrets.yml.sample | 2 + docker-compose.yml.sample | 34 +++++++++ entrypoint.sh | 35 +++++++++ files/README | 1 + 7 files changed, 281 insertions(+) create mode 100644 Dockerfile create mode 100644 config/ckeditor.yml create mode 100644 config/database.yml.sample create mode 100644 config/secrets.yml.sample create mode 100644 docker-compose.yml.sample create mode 100644 entrypoint.sh create mode 100644 files/README diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a4b3233 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,59 @@ +# Usar la imagen oficial de Redmine como base +FROM redmine:4.1.7 + +RUN apt-get update && apt-get install -y \ + shared-mime-info \ + git \ + build-essential \ + mariadb-client \ + libxml2-dev \ + libxslt-dev \ + zlib1g-dev \ + libpq-dev \ + libmariadb-dev-compat \ + libmariadb-dev \ + libssl-dev \ + libreadline-dev \ + libffi-dev \ + imagemagick \ + && rm -rf /var/lib/apt/lists/* + +# Definir el directorio de trabajo +WORKDIR /usr/src/redmine + +# Copiar archivos personalizados dentro del contenedor +COPY app/controllers/wiki_controller.rb /usr/src/redmine/app/controllers/wiki_controller.rb +COPY app/helpers/search_helper.rb /usr/src/redmine/app/helpers/search_helper.rb +COPY app/views/account/login.html.erb /usr/src/redmine/app/views/account/login.html.erb +COPY app/views/issues/tabs/_changesets.html.erb /usr/src/redmine/app/views/issues/tabs/_changesets.html.erb +COPY app/views/layouts/base.html.erb /usr/src/redmine/app/views/layouts/base.html.erb +COPY app/views/repositories/_changeset.html.erb /usr/src/redmine/app/views/repositories/_changeset.html.erb +COPY app/views/wiki/show.html.erb /usr/src/redmine/app/views/wiki/show.html.erb + +COPY config/database.yml /usr/src/redmine/config/database.yml +COPY config/secrets.yml /usr/src/redmine/config/secrets.yml +COPY config/locales/en.yml /usr/src/redmine/config/locales/en.yml +COPY config/locales/es.yml /usr/src/redmine/config/locales/es.yml + +COPY plugins /usr/src/redmine/plugins + +COPY public/themes/circlepro /usr/src/redmine/public/themes/circlepro + +# Clonar el plugin "rich" +RUN git clone https://github.com/a-ono/rich.git /usr/src/redmine/vendor/rich + +# Establecer permisos adecuados (opcional) +RUN chown -R redmine:redmine /usr/src/redmine + +# Instalar dependencias de Ruby +RUN bundle install --without development test --path vendor/bundle + +# Copiar el backup de la base de datos +COPY suitepro-backup.sql /suitepro-backup.sql + +# Copiar el script de inicialización +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +# Configurar el punto de entrada +ENTRYPOINT ["/entrypoint.sh"] diff --git a/config/ckeditor.yml b/config/ckeditor.yml new file mode 100644 index 0000000..c2adb24 --- /dev/null +++ b/config/ckeditor.yml @@ -0,0 +1,143 @@ +# CKEditor configuration: +contentsCss: '/themes/circlepro/stylesheets/editor.css' +allowedContent: true +bodyClass: 'wiki' +removePlugins: 'codemirror,div,flash,forms,iframe,copyformatting,elementspath' +forcePasteAsPlainText: false +entities: false + +# CodeSnipet plugin configuration: +codeSnippet_languages: { + apache: 'Apache', + awk: 'Awk', + bash: 'Bash', + bat: '.bat / DOS', + cpp: 'C++', + css: 'CSS', + diff: 'Diff', + dockerfile: 'Dockerfile', + html: 'HTML', + ini: '.ini / TOML', + java: 'Java', + javascript: 'JavaScript', + json: 'JSON', + makefile: 'Makefile', + markdown: 'Markdown', + nginx: 'Nginx', + php: 'PHP', + perl: 'Perl', + ruby: 'Ruby', + rust: 'Rust', + sql: 'SQL', + xhtml: 'XHTML', + xml: 'XML', + yaml: 'YAML' +} + +# Youtube plugin defaults: +youtube_responsive: true + +# HTML sanitizer configuration: +allowedProtocols: + - afs + - aim + - callto + - ed2k + - feed + - ftp + - gopher + - http + - https + - irc + - mailto + - news + - nntp + - rsync + - rtsp + - sftp + - ssh + - tag + - telnet + - urn + - webcal + - xmpp + +allowedTags: + - a + - abbr + - acronym + - address + - b + - big + - blockquote + - br + - caption + - cite + - code + - dd + - del + - dfn + - div + - dt + - em + - h1 + - h2 + - h3 + - h4 + - h5 + - h6 + - hr + - i + - iframe + - img + - ins + - kbd + - li + - ol + - p + - pre + - s + - samp + - small + - span + - strike + - strong + - sub + - sup + - table + - tbody + - td + - tfoot + - th + - thead + - tr + - tt + - u + - ul + - var + +allowedAttributes: + - abbr + - align + - alt + - border + - cellpadding + - cellspacing + - cite + - class + - colspan + - datetime + - dir + - height + - href + - name + - nowrap + - reversed + - rowspan + - src + - start + - style + - title + - valign + - width + - xml:lang diff --git a/config/database.yml.sample b/config/database.yml.sample new file mode 100644 index 0000000..ad5a2d0 --- /dev/null +++ b/config/database.yml.sample @@ -0,0 +1,7 @@ +production: + adapter: mysql2 + database: suitepro + host: db + username: suitepro + password: "" + encoding: utf8mb4 diff --git a/config/secrets.yml.sample b/config/secrets.yml.sample new file mode 100644 index 0000000..196f834 --- /dev/null +++ b/config/secrets.yml.sample @@ -0,0 +1,2 @@ +production: + secret_key_base: "" diff --git a/docker-compose.yml.sample b/docker-compose.yml.sample new file mode 100644 index 0000000..c47fdf0 --- /dev/null +++ b/docker-compose.yml.sample @@ -0,0 +1,34 @@ +version: '3' + +services: + suitepro: + build: . + container_name: suitepro + ports: + - "3080:3080" + environment: + REDMINE_DB_MYSQL: db + REDMINE_DB_DATABASE: suitepro + REDMINE_DB_USERNAME: suitepro + REDMINE_DB_PASSWORD: + volumes: + - ./files:/usr/src/redmine/files + - ./config/ckeditor.yml:/usr/src/redmine/config/ckeditor.yml + depends_on: + - db + restart: always + + db: + image: mariadb:10.5.26 + container_name: suitepro_db + environment: + MARIADB_ROOT_PASSWORD: + MARIADB_DATABASE: suitepro + MARIADB_USER: suitepro + MARIADB_PASSWORD: + volumes: + - db_data:/var/lib/mysql + restart: always + +volumes: + db_data: diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..9c75327 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +set -e + +echo "📌 Esperando a que la base de datos esté lista..." +until mysql -h db -u"$REDMINE_DB_USERNAME" -p"$REDMINE_DB_PASSWORD" -e "SELECT 1;" &> /dev/null; do + sleep 5 +done + +echo "📌 Verificando si la base de datos está preparada..." +# Comprobar si la tabla 'projects' existe +TABLE_EXISTS=$(mysql -h db -u"$REDMINE_DB_USERNAME" -p"$REDMINE_DB_PASSWORD" -D "$REDMINE_DB_DATABASE" \ + -se "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '$REDMINE_DB_DATABASE' AND table_name = 'projects';") + +if [ "$TABLE_EXISTS" -eq 0 ]; then + echo "🚀 Tabla 'projects' no existe. Importando backup..." + mysql -h db -u"$REDMINE_DB_USERNAME" -p"$REDMINE_DB_PASSWORD" "$REDMINE_DB_DATABASE" < /suitepro-backup.sql + echo "✅ Importación completada." +else + # Si la tabla existe, se comprueba si tiene registros + RECORD_COUNT=$(mysql -h db -u"$REDMINE_DB_USERNAME" -p"$REDMINE_DB_PASSWORD" -D "$REDMINE_DB_DATABASE" \ + -se "SELECT COUNT(*) FROM projects;") + if [ "$RECORD_COUNT" -eq 0 ]; then + echo "🚀 Tabla 'projects' está vacía. Importando backup..." + mysql -h db -u"$REDMINE_DB_USERNAME" -p"$REDMINE_DB_PASSWORD" "$REDMINE_DB_DATABASE" < /suitepro-backup.sql + echo "✅ Importación completada." + fi +fi + +echo "🚀 Ejecutando migraciones de plugins..." +bundle exec rake redmine:plugins:migrate RAILS_ENV=production + +# Iniciar Redmine +echo "🚀 Iniciando Redmine..." +exec rails server -b 0.0.0.0 diff --git a/files/README b/files/README new file mode 100644 index 0000000..a674aa2 --- /dev/null +++ b/files/README @@ -0,0 +1 @@ +default directory for uploaded files