Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
koha
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
arquitecturati
koha
Commits
8feb0cff
Commit
8feb0cff
authored
Jun 25, 2026
by
arquitecturati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Se aagrega readme y profiles en dockerfile
parent
56b79471
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
132 additions
and
24 deletions
+132
-24
.env.example
.env.example
+7
-0
Dockerfile
Dockerfile
+15
-1
README.md
README.md
+0
-0
docker-compose.yml
docker-compose.yml
+27
-7
entrypoint.sh
docker/entrypoint.sh
+83
-16
No files found.
.env.example
View file @
8feb0cff
...
...
@@ -21,3 +21,10 @@ KOHA_INTRA_SERVER_NAME=koha-intra.local
# Memcached (interno al contenedor — no cambiar)
MEMCACHED_SERVERS=127.0.0.1:11211
# Timezone para conexiones MySQL/MariaDB
# Si la BD NO tiene cargadas las tablas mysql.time_zone* (típico en MariaDB
# self-hosted), usar un offset UTC: -05:00 para Bogotá (UTC-5, sin DST).
# Si la BD tiene las tablas cargadas (mysql_tzinfo_to_sql), se puede usar
# America/Bogota directamente.
KOHA_TIMEZONE=-05:00
Dockerfile
View file @
8feb0cff
...
...
@@ -27,6 +27,15 @@ RUN wget -qO- https://debian.koha-community.org/koha/gpg.asc \
RUN
apt-get update
&&
apt-get install
-y
koha-common
\
&&
rm
-rf
/var/lib/apt/lists/
*
# Bug en scripts shell de Koha: usan "xmlstarlet sel -t -v" sin -T, lo que
# re-escapa entidades XML al output (& → &). Passwords con caracteres
# como & quedan mal cuando koha-mysql los pasa al cliente mysql. Parche:
# agregar -T para que xmlstarlet emita texto plano decodificado.
RUN for
f
in
/usr/sbin/koha-
*
/usr/share/koha/bin/
*
.sh
;
do
\
[
-f
"
$f
"
]
&&
grep
-q
"xmlstarlet sel -t"
"
$f
"
&&
\
sed
-i
's|xmlstarlet sel -t |xmlstarlet sel -T -t |g'
"
$f
"
;
\
done
;
true
# List::MoreUtils: la versión de Ubuntu 20.04 no exporta zip6 correctamente.
# cpanm instala una versión consistente PP+XS desde CPAN.
RUN
apt-get update
&&
apt-get install
-y
cpanminus build-essential
&&
\
...
...
@@ -54,7 +63,12 @@ RUN apt-get update && \
echo
"MySQL client activo:
$(
mysql
--version
)
"
# Fase 3.7 — Habilitar módulos Apache requeridos
RUN
a2enmod rewrite cgi headers proxy_http
# remoteip: leer X-Forwarded-For del ALB y reemplazar REMOTE_ADDR
RUN
a2enmod rewrite cgi headers proxy_http remoteip
# Fase 3.8 — Configuración para ALB / reverse proxy
COPY
docker/alb-proxy.conf /etc/apache2/conf-available/alb-proxy.conf
RUN
a2enconf alb-proxy
# --- Archivos de migración ---
# SQL dump de la base de datos (Fase 4.1)
...
...
README.md
0 → 100644
View file @
8feb0cff
This diff is collapsed.
Click to expand it.
docker-compose.yml
View file @
8feb0cff
services
:
# -------------------------------------------------------
# BD local para pruebas —
reemplaza al RDS en desarrollo.
# Para
usar RDS real: comentar este bloque y ajustar
.env
# BD local para pruebas —
solo activa con: --profile local
# Para
RDS: no pasar el perfil y ajustar DB_HOST en
.env
# -------------------------------------------------------
db
:
profiles
:
[
"
local"
]
image
:
mariadb:10.6
environment
:
MYSQL_ROOT_PASSWORD
:
${DB_ADMIN_PASSWORD}
...
...
@@ -24,19 +25,38 @@ services:
ports
:
-
"
8080:80"
env_file
:
.env
environment
:
# Apuntar al servicio db local en vez del RDS
DB_HOST
:
db
depends_on
:
db
:
condition
:
service_healthy
required
:
false
# ignorado cuando db no está activa (perfil RDS)
volumes
:
# Persistir estado de inicialización, uploads, plugins e índices Zebra.
# Si se elimina este volumen, el entrypoint ejecuta la restauración completa.
-
koha_data:/var/lib/koha
-
koha_logs:/var/log/koha
restart
:
unless-stopped
# -------------------------------------------------------
# Proxy nginx local — simula el ALB con terminación TLS.
# Solo activa con: --profile local
#
# Antes del primer uso ejecutar:
# bash docker/gen-local-certs.sh
#
# Flujo de prueba ALB:
# https://koha.local → nginx (443) → koha:80 (X-Forwarded-Proto: https)
# https://koha-intra.local → nginx (443) → koha:80 (X-Forwarded-Proto: https)
# -------------------------------------------------------
proxy
:
profiles
:
[
"
local"
]
image
:
nginx:alpine
ports
:
-
"
80:80"
-
"
443:443"
volumes
:
-
./docker/nginx-local.conf:/etc/nginx/nginx.conf:ro
-
./docker/certs:/etc/nginx/certs:ro
depends_on
:
-
koha
volumes
:
db_data
:
koha_data
:
...
...
docker/entrypoint.sh
View file @
8feb0cff
...
...
@@ -8,6 +8,28 @@ INIT_FLAG="/var/lib/koha/${INSTANCE}/.docker_initialized"
echo
"ServerName localhost"
>>
/etc/apache2/apache2.conf
# -------------------------------------------------------
# Health check temporal — responde HTTP 200 en puerto 80
# desde el primer segundo del arranque, incluso durante el
# FIRST_RUN (DB restore puede tardar 10-20 min en ECS).
# ECS ve siempre 200 → no reinicia el task por timeout.
# Se mata justo antes de que Apache tome el puerto.
# -------------------------------------------------------
python3
-c
"
import http.server, socketserver
class H(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.end_headers()
self.wfile.write(b'starting')
def log_message(self, *a): pass
socketserver.TCPServer.allow_reuse_address = True
with socketserver.TCPServer(('', 8099), H) as s:
s.serve_forever()
"
&
HEALTHCHECK_PID
=
$!
echo
"[koha] Health check temporal iniciado (pid
${
HEALTHCHECK_PID
}
)"
# -------------------------------------------------------
# Aplica variables de entorno sobre la plantilla koha-conf.xml.
# Se llama tanto en el primer arranque como en reinicios.
# -------------------------------------------------------
...
...
@@ -15,16 +37,38 @@ apply_koha_config() {
local
tpl
=
"/etc/koha/koha-conf.xml.tpl"
local
dst
=
"/etc/koha/sites/
${
INSTANCE
}
/koha-conf.xml"
sed
\
-e
"s|<hostname>localhost</hostname>|<hostname>
${
DB_HOST
}
</hostname>|g"
\
-e
"s|<port>3306</port>|<port>
${
DB_PORT
:-
3306
}
</port>|g"
\
-e
"s|<database>koha_prod_humboldt</database>|<database>
${
DB_NAME
:-
koha_prod_humboldt
}
</database>|g"
\
-e
"s|<user>koha_prod_humboldt</user>|<user>
${
DB_USER
:-
koha_prod_humboldt
}
</user>|g"
\
-e
"s|<pass>KohaProd2026!Secure</pass>|<pass>
${
DB_PASSWORD
}
</pass>|g"
\
-e
"s|<memcached_servers>127
\.
0
\.
0
\.
1:11211</memcached_servers>|<memcached_servers>
${
MEMCACHED_SERVERS
:-
127
.0.0.1
:11211
}
</memcached_servers>|g"
\
"
${
tpl
}
"
>
"
${
dst
}
"
echo
"[koha] koha-conf.xml aplicado (DB_HOST=
${
DB_HOST
}
)"
# Perl en vez de sed: el password puede tener caracteres que rompen sed
# (& en el reemplazo = "todo lo matcheado") y bash parameter expansion
# también trata & especial. Perl hace XML-encoding y string replace limpio.
DB_HOST
=
"
$DB_HOST
"
\
DB_PORT
=
"
${
DB_PORT
:-
3306
}
"
\
DB_NAME
=
"
${
DB_NAME
:-
koha_prod_humboldt
}
"
\
DB_USER
=
"
${
DB_USER
:-
koha_prod_humboldt
}
"
\
DB_PASSWORD
=
"
$DB_PASSWORD
"
\
MEMCACHED_SERVERS
=
"
${
MEMCACHED_SERVERS
:-
127
.0.0.1
:11211
}
"
\
KOHA_TIMEZONE
=
"
${
KOHA_TIMEZONE
:-
-05
:00
}
"
\
perl
-p
-e
'
BEGIN {
for my $k (qw(DB_HOST DB_PORT DB_NAME DB_USER DB_PASSWORD MEMCACHED_SERVERS KOHA_TIMEZONE)) {
my $v = $ENV{$k};
$v =~ s/&/&/g;
$v =~ s/</</g;
$v =~ s/>/>/g;
$v =~ s/"/"/g;
$v =~ s/\x27/'/g;
$enc{$k} = $v;
}
}
s|<hostname>localhost</hostname>|<hostname>$enc{DB_HOST}</hostname>|g;
s|<port>3306</port>|<port>$enc{DB_PORT}</port>|g;
s|<database>koha_prod_humboldt</database>|<database>$enc{DB_NAME}</database>|g;
s|<user>koha_prod_humboldt</user>|<user>$enc{DB_USER}</user>|g;
s|<pass>KohaProd2026!Secure</pass>|<pass>$enc{DB_PASSWORD}</pass>|g;
s|<memcached_servers>127\.0\.0\.1:11211</memcached_servers>|<memcached_servers>$enc{MEMCACHED_SERVERS}</memcached_servers>|g;
s|<timezone>[^<]*</timezone>|<timezone>$enc{KOHA_TIMEZONE}</timezone>|g;
'
"
$tpl
"
>
"
$dst
"
echo
"[koha] koha-conf.xml aplicado (DB_HOST=
$DB_HOST
)"
}
# -------------------------------------------------------
...
...
@@ -123,7 +167,8 @@ if [ ! -f "${INIT_FLAG}" ]; then
echo
"SET sql_mode='';"
zcat /migration/prod_humboldt-2026-04-30.sql.gz
\
| awk
'BEGIN{prev=""} /^\s*CONSTRAINT .* FOREIGN KEY/{sub(/,\s*$/,"",prev); if(prev!="") print prev; prev=""; next} {if(prev!="") print prev; prev=$0} END{if(prev!="") print prev}'
\
|
grep
-v
"ADD CONSTRAINT.*FOREIGN KEY"
|
grep
-v
"ADD CONSTRAINT.*FOREIGN KEY"
\
|
grep
-Eiv
"^
\s
*(GRANT|REVOKE|CREATE USER|DROP USER|ALTER USER|SET PASSWORD)
\b
"
echo
"SET FOREIGN_KEY_CHECKS=1;"
echo
"SET UNIQUE_CHECKS=1;"
}
| koha-mysql
"
${
INSTANCE
}
"
...
...
@@ -190,16 +235,36 @@ if [ ! -f "${INIT_FLAG}" ]; then
fi
# -------------------------------------------------------
# Sincronizar OPACBaseURL / staffClientBaseURL con las variables de entorno.
# Se ejecuta en cada arranque para que un cambio de dominio (ej. local → prod)
# se refleje sin entrar al panel de administración.
# Las URLs usan https:// porque el ALB siempre termina TLS; en local el nginx
# proxy también usa HTTPS, por lo que el esquema es siempre correcto.
# -------------------------------------------------------
koha-mysql
"
${
INSTANCE
}
"
-e
"
UPDATE systempreferences
SET value='https://
${
KOHA_OPAC_SERVER_NAME
}
'
WHERE variable='OPACBaseURL';
UPDATE systempreferences
SET value='https://
${
KOHA_INTRA_SERVER_NAME
}
'
WHERE variable='staffClientBaseURL';"
2>/dev/null
||
true
# -------------------------------------------------------
# Limpiar PIDs stale de ejecuciones anteriores
# -------------------------------------------------------
rm
-f
/var/run/koha/
"
${
INSTANCE
}
"
/
*
.pid 2>/dev/null
||
true
# Garantizar permisos en logs para el usuario de la instancia (Plack escribe aquí)
chown
-R
"
${
INSTANCE
}
-koha:
${
INSTANCE
}
-koha"
"/var/log/koha/
${
INSTANCE
}
/"
2>/dev/null
||
true
# -------------------------------------------------------
# Fase 5 — Arranque de servicios
# -------------------------------------------------------
# Pre-crear los archivos de log con ownership correcto ANTES de cualquier
# servicio. koha-plack --start dispara "apache2 restart" que crea opac-error.log
# e intranet-error.log como root; si ya existen con ownership prod_humboldt-koha
# Apache los abre en modo append sin cambiar el owner, y Plack puede escribir.
mkdir
-p
"/var/log/koha/
${
INSTANCE
}
"
touch
"/var/log/koha/
${
INSTANCE
}
/opac-error.log"
\
"/var/log/koha/
${
INSTANCE
}
/intranet-error.log"
chown
-R
"
${
INSTANCE
}
-koha:
${
INSTANCE
}
-koha"
"/var/log/koha/
${
INSTANCE
}
/"
echo
"[koha] Iniciando Memcached..."
service memcached start
...
...
@@ -226,8 +291,10 @@ echo "[koha] OPAC: http://${KOHA_OPAC_SERVER_NAME:-koha.local}"
echo
"[koha] Intranet: http://
${
KOHA_INTRA_SERVER_NAME
:-
koha
-intra.local
}
"
echo
""
# koha-plack --start hace service apache2 restart en Koha 25.11.
# Detener y limpiar antes de tomar el control en foreground.
# Liberar puerto 80 antes de que Apache arranque en foreground
kill
"
${
HEALTHCHECK_PID
}
"
2>/dev/null
||
true
wait
"
${
HEALTHCHECK_PID
}
"
2>/dev/null
||
true
service apache2 stop 2>/dev/null
||
true
rm
-f
/var/run/apache2/apache2.pid 2>/dev/null
||
true
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment