🔨 Integra scripts y código para docker

This commit is contained in:
Manuel Cillero 2025-06-22 01:16:32 +02:00
parent 4cea38117d
commit 3d487e4279
7 changed files with 281 additions and 0 deletions

59
Dockerfile Normal file
View file

@ -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"]

143
config/ckeditor.yml Normal file
View file

@ -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

View file

@ -0,0 +1,7 @@
production:
adapter: mysql2
database: suitepro
host: db
username: suitepro
password: "<contraseña>"
encoding: utf8mb4

View file

@ -0,0 +1,2 @@
production:
secret_key_base: "<clave>"

34
docker-compose.yml.sample Normal file
View file

@ -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: <contraseña>
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: <contraseña>
MARIADB_DATABASE: suitepro
MARIADB_USER: suitepro
MARIADB_PASSWORD: <contraseña>
volumes:
- db_data:/var/lib/mysql
restart: always
volumes:
db_data:

35
entrypoint.sh Normal file
View file

@ -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

1
files/README Normal file
View file

@ -0,0 +1 @@
default directory for uploaded files