25/12/2025
This commit is contained in:
parent
bded2893ab
commit
a0eb45ac03
Binary file not shown.
@ -1,6 +1,6 @@
|
|||||||
FROM debian:bullseye-slim
|
FROM debian:bullseye-slim
|
||||||
|
|
||||||
# Installation des dépendances de base
|
# Installation des dépendances de base + PostgreSQL
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
apache2 \
|
apache2 \
|
||||||
supervisor \
|
supervisor \
|
||||||
@ -10,6 +10,8 @@ RUN apt-get update && apt-get install -y \
|
|||||||
gnupg \
|
gnupg \
|
||||||
lsb-release \
|
lsb-release \
|
||||||
openjdk-17-jdk \
|
openjdk-17-jdk \
|
||||||
|
postgresql-13 \
|
||||||
|
postgresql-contrib \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Installation de Tomcat 10
|
# Installation de Tomcat 10
|
||||||
@ -20,7 +22,7 @@ RUN cd /opt && \
|
|||||||
rm apache-tomcat-10.1.47.tar.gz && \
|
rm apache-tomcat-10.1.47.tar.gz && \
|
||||||
chmod +x /opt/tomcat/bin/*.sh
|
chmod +x /opt/tomcat/bin/*.sh
|
||||||
|
|
||||||
# Variables d'environnement Tomcat
|
# Variables d'environnement
|
||||||
ENV CATALINA_HOME=/opt/tomcat
|
ENV CATALINA_HOME=/opt/tomcat
|
||||||
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
|
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
|
||||||
ENV PATH=$PATH:$CATALINA_HOME/bin
|
ENV PATH=$PATH:$CATALINA_HOME/bin
|
||||||
@ -44,12 +46,64 @@ RUN wget https://github.com/grafana/loki/releases/download/v2.9.0/promtail-linux
|
|||||||
&& chmod +x /usr/local/bin/promtail \
|
&& chmod +x /usr/local/bin/promtail \
|
||||||
&& rm promtail-linux-amd64.zip
|
&& rm promtail-linux-amd64.zip
|
||||||
|
|
||||||
|
# Suppression et recréation des répertoires PostgreSQL
|
||||||
|
RUN rm -rf /var/lib/postgresql/13/main && \
|
||||||
|
mkdir -p /var/run/postgresql \
|
||||||
|
/var/lib/postgresql/13/main \
|
||||||
|
/var/log/postgresql \
|
||||||
|
/var/log/apache2 \
|
||||||
|
/var/log/promtail \
|
||||||
|
/opt/tomcat/logs \
|
||||||
|
/var/log/supervisor \
|
||||||
|
/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
|
||||||
|
|
||||||
|
# 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
|
||||||
|
RUN echo '#!/bin/bash\n\
|
||||||
|
echo "Waiting for PostgreSQL to start..."\n\
|
||||||
|
for i in {1..30}; do\n\
|
||||||
|
if su - postgres -c "psql -c \"SELECT 1;\"" >/dev/null 2>&1; then\n\
|
||||||
|
echo "PostgreSQL is ready!"\n\
|
||||||
|
break\n\
|
||||||
|
fi\n\
|
||||||
|
echo "Waiting... ($i/30)"\n\
|
||||||
|
sleep 1\n\
|
||||||
|
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 \"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\
|
||||||
|
echo "Executing SQL scripts..."\n\
|
||||||
|
if [ -f /docker-entrypoint-initdb.d/01-schema.sql ]; then\n\
|
||||||
|
echo "Running schema.sql..."\n\
|
||||||
|
su - postgres -c "psql -d archiweb_db -f /docker-entrypoint-initdb.d/01-schema.sql"\n\
|
||||||
|
fi\n\
|
||||||
|
\n\
|
||||||
|
if [ -f /docker-entrypoint-initdb.d/02-data.sql ]; then\n\
|
||||||
|
echo "Running data.sql..."\n\
|
||||||
|
su - postgres -c "psql -d archiweb_db -f /docker-entrypoint-initdb.d/02-data.sql"\n\
|
||||||
|
fi\n\
|
||||||
|
\n\
|
||||||
|
echo "Database setup complete!"' > /usr/local/bin/init-database.sh && \
|
||||||
|
chmod +x /usr/local/bin/init-database.sh
|
||||||
|
|
||||||
# Copie des configurations
|
# Copie des configurations
|
||||||
COPY configs/apache/httpd.conf /etc/apache2/sites-available/000-default.conf
|
|
||||||
COPY configs/promtail/config.yaml /etc/promtail/config.yaml
|
COPY configs/promtail/config.yaml /etc/promtail/config.yaml
|
||||||
COPY configs/supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
COPY configs/supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||||
|
|
||||||
# Configuration Apache pour server-status
|
# Configuration Apache
|
||||||
RUN echo '<Location "/server-status">\n\
|
RUN echo '<Location "/server-status">\n\
|
||||||
SetHandler server-status\n\
|
SetHandler server-status\n\
|
||||||
Require all granted\n\
|
Require all granted\n\
|
||||||
@ -66,12 +120,9 @@ RUN echo '<VirtualHost *:80>\n\
|
|||||||
ProxyPassReverse /api http://localhost:8080/api\n\
|
ProxyPassReverse /api http://localhost:8080/api\n\
|
||||||
</VirtualHost>' > /etc/apache2/sites-available/000-default.conf
|
</VirtualHost>' > /etc/apache2/sites-available/000-default.conf
|
||||||
|
|
||||||
# Création des répertoires de logs
|
# Copie du WAR
|
||||||
RUN mkdir -p /var/log/apache2 /var/log/promtail /opt/tomcat/logs
|
|
||||||
|
|
||||||
# Copie du WAR (à placer dans le contexte de build)
|
|
||||||
COPY archiweb-api-1.0.0.war /opt/tomcat/webapps/api.war
|
COPY archiweb-api-1.0.0.war /opt/tomcat/webapps/api.war
|
||||||
|
|
||||||
EXPOSE 80 8080 9100 9117 9080
|
EXPOSE 80 8080 9100 9117 9080 5432
|
||||||
|
|
||||||
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|
||||||
|
|||||||
@ -4,23 +4,44 @@ user=root
|
|||||||
logfile=/var/log/supervisor/supervisord.log
|
logfile=/var/log/supervisor/supervisord.log
|
||||||
pidfile=/var/run/supervisord.pid
|
pidfile=/var/run/supervisord.pid
|
||||||
|
|
||||||
|
[program:postgresql]
|
||||||
|
command=/usr/lib/postgresql/13/bin/postgres -D /var/lib/postgresql/13/main
|
||||||
|
user=postgres
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
priority=1
|
||||||
|
stdout_logfile=/var/log/postgresql/postgresql.log
|
||||||
|
stderr_logfile=/var/log/postgresql/postgresql-error.log
|
||||||
|
startsecs=5
|
||||||
|
stopwaitsecs=30
|
||||||
|
|
||||||
|
[program:init-database]
|
||||||
|
command=/usr/local/bin/init-database.sh
|
||||||
|
autostart=true
|
||||||
|
autorestart=false
|
||||||
|
priority=5
|
||||||
|
stdout_logfile=/var/log/postgresql/init-database.log
|
||||||
|
stderr_logfile=/var/log/postgresql/init-database-error.log
|
||||||
|
startsecs=0
|
||||||
|
|
||||||
[program:apache2]
|
[program:apache2]
|
||||||
command=/usr/sbin/apache2ctl -D FOREGROUND
|
command=/usr/sbin/apache2ctl -D FOREGROUND
|
||||||
autostart=true
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
stdout_logfile=/var/log/apache2/access.log
|
stdout_logfile=/var/log/apache2/access.log
|
||||||
stderr_logfile=/var/log/apache2/error.log
|
stderr_logfile=/var/log/apache2/error.log
|
||||||
priority=1
|
priority=10
|
||||||
|
startsecs=5
|
||||||
|
|
||||||
[program:tomcat]
|
[program:tomcat]
|
||||||
command=/opt/tomcat/bin/catalina.sh run
|
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"
|
environment=JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64",CATALINA_HOME="/opt/tomcat"
|
||||||
autostart=true
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
stdout_logfile=/opt/tomcat/logs/catalina.out
|
stdout_logfile=/opt/tomcat/logs/catalina.out
|
||||||
stderr_logfile=/opt/tomcat/logs/catalina.out
|
stderr_logfile=/opt/tomcat/logs/catalina.out
|
||||||
priority=1
|
priority=15
|
||||||
startsecs=30
|
startsecs=35
|
||||||
stopwaitsecs=30
|
stopwaitsecs=30
|
||||||
|
|
||||||
[program:node_exporter]
|
[program:node_exporter]
|
||||||
@ -31,7 +52,8 @@ stdout_logfile=/dev/stdout
|
|||||||
stdout_logfile_maxbytes=0
|
stdout_logfile_maxbytes=0
|
||||||
stderr_logfile=/dev/stderr
|
stderr_logfile=/dev/stderr
|
||||||
stderr_logfile_maxbytes=0
|
stderr_logfile_maxbytes=0
|
||||||
priority=2
|
priority=20
|
||||||
|
startsecs=5
|
||||||
|
|
||||||
[program:apache_exporter]
|
[program:apache_exporter]
|
||||||
command=/usr/local/bin/apache_exporter --scrape_uri=http://localhost/server-status?auto
|
command=/usr/local/bin/apache_exporter --scrape_uri=http://localhost/server-status?auto
|
||||||
@ -39,7 +61,7 @@ autostart=true
|
|||||||
autorestart=true
|
autorestart=true
|
||||||
stdout_logfile=/var/log/apache_exporter.log
|
stdout_logfile=/var/log/apache_exporter.log
|
||||||
stderr_logfile=/var/log/apache_exporter_error.log
|
stderr_logfile=/var/log/apache_exporter_error.log
|
||||||
priority=2
|
priority=20
|
||||||
startsecs=5
|
startsecs=5
|
||||||
|
|
||||||
[program:promtail]
|
[program:promtail]
|
||||||
@ -48,5 +70,5 @@ autostart=true
|
|||||||
autorestart=true
|
autorestart=true
|
||||||
stdout_logfile=/var/log/promtail/promtail.log
|
stdout_logfile=/var/log/promtail/promtail.log
|
||||||
stderr_logfile=/var/log/promtail/promtail_error.log
|
stderr_logfile=/var/log/promtail/promtail_error.log
|
||||||
priority=3
|
priority=25
|
||||||
startsecs=5
|
startsecs=5
|
||||||
|
|||||||
@ -19,6 +19,7 @@ CREATE TABLE utilisateur
|
|||||||
nom VARCHAR(100),
|
nom VARCHAR(100),
|
||||||
prenom VARCHAR(100),
|
prenom VARCHAR(100),
|
||||||
email VARCHAR(255),
|
email VARCHAR(255),
|
||||||
|
token_reinitialisation VARCHAR(255),
|
||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id),
|
||||||
CONSTRAINT ux_u_login UNIQUE (login),
|
CONSTRAINT ux_u_login UNIQUE (login),
|
||||||
CONSTRAINT ux_u_email UNIQUE (email)
|
CONSTRAINT ux_u_email UNIQUE (email)
|
||||||
|
|||||||
@ -9,14 +9,17 @@ services:
|
|||||||
- "9117:9117"
|
- "9117:9117"
|
||||||
- "9101:9100"
|
- "9101:9100"
|
||||||
- "9080:9080"
|
- "9080:9080"
|
||||||
|
- "5432:5432"
|
||||||
volumes:
|
volumes:
|
||||||
- apache-logs:/var/log/apache2
|
- apache-logs:/var/log/apache2
|
||||||
|
- postgres-data:/var/lib/postgresql/data
|
||||||
networks:
|
networks:
|
||||||
- centre_observabilite_observability
|
- centre_observabilite_observability
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
apache-logs:
|
apache-logs:
|
||||||
|
postgres-data:
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
centre_observabilite_observability:
|
centre_observabilite_observability:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user