MAJ
This commit is contained in:
parent
27083ef19b
commit
0561442e78
@ -1,6 +1,6 @@
|
||||
FROM debian:bullseye-slim
|
||||
|
||||
# Installation des dépendances de base + PostgreSQL
|
||||
# Installation des dépendances de base
|
||||
RUN apt-get update && apt-get install -y \
|
||||
apache2 \
|
||||
supervisor \
|
||||
@ -10,10 +10,15 @@ RUN apt-get update && apt-get install -y \
|
||||
gnupg \
|
||||
lsb-release \
|
||||
openjdk-17-jdk \
|
||||
postgresql-13 \
|
||||
postgresql-contrib \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Installation de PostgreSQL 18 depuis le dépôt officiel
|
||||
RUN echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
|
||||
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
|
||||
apt-get update && \
|
||||
apt-get install -y postgresql-18 postgresql-client-18 postgresql-contrib && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Installation de Tomcat 10
|
||||
RUN cd /opt && \
|
||||
wget https://archive.apache.org/dist/tomcat/tomcat-10/v10.1.47/bin/apache-tomcat-10.1.47.tar.gz && \
|
||||
@ -46,10 +51,10 @@ RUN wget https://github.com/grafana/loki/releases/download/v2.9.0/promtail-linux
|
||||
&& chmod +x /usr/local/bin/promtail \
|
||||
&& rm promtail-linux-amd64.zip
|
||||
|
||||
# Suppression et recréation des répertoires PostgreSQL
|
||||
RUN rm -rf /var/lib/postgresql/13/main && \
|
||||
# Suppression et recréation des répertoires PostgreSQL 18
|
||||
RUN rm -rf /var/lib/postgresql/18/main && \
|
||||
mkdir -p /var/run/postgresql \
|
||||
/var/lib/postgresql/13/main \
|
||||
/var/lib/postgresql/18/main \
|
||||
/var/log/postgresql \
|
||||
/var/log/apache2 \
|
||||
/var/log/promtail \
|
||||
@ -58,16 +63,20 @@ RUN rm -rf /var/lib/postgresql/13/main && \
|
||||
/docker-entrypoint-initdb.d && \
|
||||
chown -R postgres:postgres /var/run/postgresql /var/lib/postgresql /var/log/postgresql
|
||||
|
||||
# Initialisation de PostgreSQL
|
||||
RUN su - postgres -c "/usr/lib/postgresql/13/bin/initdb -D /var/lib/postgresql/13/main" && \
|
||||
echo "host all all 0.0.0.0/0 md5" >> /var/lib/postgresql/13/main/pg_hba.conf && \
|
||||
echo "listen_addresses='*'" >> /var/lib/postgresql/13/main/postgresql.conf
|
||||
# Initialisation de PostgreSQL 18
|
||||
RUN su - postgres -c "/usr/lib/postgresql/18/bin/initdb -D /var/lib/postgresql/18/main" && \
|
||||
echo "host all all 0.0.0.0/0 md5" >> /var/lib/postgresql/18/main/pg_hba.conf && \
|
||||
echo "listen_addresses='*'" >> /var/lib/postgresql/18/main/postgresql.conf
|
||||
|
||||
# Modification du pg_hba.conf pour utiliser md5 au lieu de peer (comme dans le script bash)
|
||||
RUN sed -i "s/^local\s\+all\s\+all\s\+peer/local all all md5/" /var/lib/postgresql/18/main/pg_hba.conf
|
||||
|
||||
# Copie des scripts SQL
|
||||
COPY database/schema.sql /docker-entrypoint-initdb.d/01-schema.sql
|
||||
COPY database/data.sql /docker-entrypoint-initdb.d/02-data.sql
|
||||
|
||||
# Script pour créer la base de données et exécuter les scripts SQL
|
||||
# Mot de passe changé en archiweb_pass
|
||||
RUN echo '#!/bin/bash\n\
|
||||
echo "Waiting for PostgreSQL to start..."\n\
|
||||
for i in {1..30}; do\n\
|
||||
@ -81,7 +90,7 @@ done\n\
|
||||
\n\
|
||||
echo "Creating database and user..."\n\
|
||||
su - postgres -c "psql -c \"SELECT 1 FROM pg_database WHERE datname = '\''archiweb_db'\''\" | grep -q 1 || psql -c \"CREATE DATABASE archiweb_db;\""\n\
|
||||
su - postgres -c "psql -c \"SELECT 1 FROM pg_roles WHERE rolname = '\''archiweb_user'\''\" | grep -q 1 || psql -c \"CREATE USER archiweb_user WITH PASSWORD '\''archiweb_password'\'';\""\n\
|
||||
su - postgres -c "psql -c \"SELECT 1 FROM pg_roles WHERE rolname = '\''archiweb_user'\''\" | grep -q 1 || psql -c \"CREATE USER archiweb_user WITH ENCRYPTED PASSWORD '\''archiweb_pass'\'';\""\n\
|
||||
su - postgres -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE archiweb_db TO archiweb_user;\""\n\
|
||||
su - postgres -c "psql -d archiweb_db -c \"GRANT ALL ON SCHEMA public TO archiweb_user;\""\n\
|
||||
\n\
|
||||
|
||||
@ -4,8 +4,9 @@ user=root
|
||||
logfile=/var/log/supervisor/supervisord.log
|
||||
pidfile=/var/run/supervisord.pid
|
||||
|
||||
# 1. PostgreSQL - PRIORITÉ 1 (démarre en premier)
|
||||
[program:postgresql]
|
||||
command=/usr/lib/postgresql/13/bin/postgres -D /var/lib/postgresql/13/main
|
||||
command=/usr/lib/postgresql/18/bin/postgres -D /var/lib/postgresql/18/main
|
||||
user=postgres
|
||||
autostart=true
|
||||
autorestart=true
|
||||
@ -15,60 +16,66 @@ stderr_logfile=/var/log/postgresql/postgresql-error.log
|
||||
startsecs=5
|
||||
stopwaitsecs=30
|
||||
|
||||
# 2. Init Database - PRIORITÉ 5 (après PostgreSQL)
|
||||
[program:init-database]
|
||||
command=/usr/local/bin/init-database.sh
|
||||
autostart=true
|
||||
autorestart=false
|
||||
startsecs=0
|
||||
priority=5
|
||||
stdout_logfile=/var/log/postgresql/init-database.log
|
||||
stderr_logfile=/var/log/postgresql/init-database-error.log
|
||||
startsecs=0
|
||||
|
||||
# 4. Tomcat - PRIORITÉ 15 (après init-database + délai)
|
||||
[program:tomcat]
|
||||
command=/bin/bash -c 'sleep 20 && /opt/tomcat/bin/catalina.sh run'
|
||||
autostart=true
|
||||
autorestart=true
|
||||
priority=15
|
||||
stdout_logfile=/opt/tomcat/logs/catalina.out
|
||||
stderr_logfile=/opt/tomcat/logs/catalina.out
|
||||
environment=JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64",CATALINA_HOME="/opt/tomcat"
|
||||
startsecs=35
|
||||
stopwaitsecs=30
|
||||
|
||||
# 3. Apache - PRIORITÉ 10
|
||||
[program:apache2]
|
||||
command=/usr/sbin/apache2ctl -D FOREGROUND
|
||||
autostart=true
|
||||
autorestart=true
|
||||
priority=10
|
||||
stdout_logfile=/var/log/apache2/access.log
|
||||
stderr_logfile=/var/log/apache2/error.log
|
||||
priority=10
|
||||
startsecs=5
|
||||
|
||||
[program:tomcat]
|
||||
command=/bin/bash -c 'sleep 20 && /opt/tomcat/bin/catalina.sh run'
|
||||
environment=JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64",CATALINA_HOME="/opt/tomcat"
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stdout_logfile=/opt/tomcat/logs/catalina.out
|
||||
stderr_logfile=/opt/tomcat/logs/catalina.out
|
||||
priority=15
|
||||
startsecs=35
|
||||
stopwaitsecs=30
|
||||
|
||||
# 5. Node Exporter - PRIORITÉ 20
|
||||
[program:node_exporter]
|
||||
command=/usr/local/bin/node_exporter
|
||||
autostart=true
|
||||
autorestart=true
|
||||
priority=20
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
priority=20
|
||||
startsecs=5
|
||||
|
||||
# 6. Apache Exporter - PRIORITÉ 20
|
||||
[program:apache_exporter]
|
||||
command=/usr/local/bin/apache_exporter --scrape_uri=http://localhost/server-status?auto
|
||||
autostart=true
|
||||
autorestart=true
|
||||
priority=20
|
||||
stdout_logfile=/var/log/apache_exporter.log
|
||||
stderr_logfile=/var/log/apache_exporter_error.log
|
||||
priority=20
|
||||
startsecs=5
|
||||
|
||||
# 7. Promtail - PRIORITÉ 25
|
||||
[program:promtail]
|
||||
command=/usr/local/bin/promtail -config.file=/etc/promtail/config.yaml
|
||||
autostart=true
|
||||
autorestart=true
|
||||
priority=25
|
||||
stdout_logfile=/var/log/promtail/promtail.log
|
||||
stderr_logfile=/var/log/promtail/promtail_error.log
|
||||
priority=25
|
||||
startsecs=5
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user