Compare commits

..

No commits in common. "a0eb45ac0360ed806c1a547c22e2f2c23379743d" and "eee26a9b80b7985358898566c5fcf1918113296b" have entirely different histories.

24 changed files with 16 additions and 93 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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,8 +10,6 @@ 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 Tomcat 10
@ -22,7 +20,7 @@ RUN cd /opt && \
rm apache-tomcat-10.1.47.tar.gz && \
chmod +x /opt/tomcat/bin/*.sh
# Variables d'environnement
# Variables d'environnement Tomcat
ENV CATALINA_HOME=/opt/tomcat
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
ENV PATH=$PATH:$CATALINA_HOME/bin
@ -46,64 +44,12 @@ 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 && \
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
COPY configs/apache/httpd.conf /etc/apache2/sites-available/000-default.conf
COPY configs/promtail/config.yaml /etc/promtail/config.yaml
COPY configs/supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Configuration Apache
# Configuration Apache pour server-status
RUN echo '<Location "/server-status">\n\
SetHandler server-status\n\
Require all granted\n\
@ -120,9 +66,12 @@ RUN echo '<VirtualHost *:80>\n\
ProxyPassReverse /api http://localhost:8080/api\n\
</VirtualHost>' > /etc/apache2/sites-available/000-default.conf
# Copie du WAR
# Création des répertoires de logs
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
EXPOSE 80 8080 9100 9117 9080 5432
EXPOSE 80 8080 9100 9117 9080
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

View File

@ -4,44 +4,23 @@ user=root
logfile=/var/log/supervisor/supervisord.log
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]
command=/usr/sbin/apache2ctl -D FOREGROUND
autostart=true
autorestart=true
stdout_logfile=/var/log/apache2/access.log
stderr_logfile=/var/log/apache2/error.log
priority=10
startsecs=5
priority=1
[program:tomcat]
command=/bin/bash -c 'sleep 20 && /opt/tomcat/bin/catalina.sh run'
command=/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
priority=1
startsecs=30
stopwaitsecs=30
[program:node_exporter]
@ -52,8 +31,7 @@ stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
priority=20
startsecs=5
priority=2
[program:apache_exporter]
command=/usr/local/bin/apache_exporter --scrape_uri=http://localhost/server-status?auto
@ -61,7 +39,7 @@ autostart=true
autorestart=true
stdout_logfile=/var/log/apache_exporter.log
stderr_logfile=/var/log/apache_exporter_error.log
priority=20
priority=2
startsecs=5
[program:promtail]
@ -70,5 +48,5 @@ autostart=true
autorestart=true
stdout_logfile=/var/log/promtail/promtail.log
stderr_logfile=/var/log/promtail/promtail_error.log
priority=25
priority=3
startsecs=5

View File

@ -19,7 +19,6 @@ CREATE TABLE utilisateur
nom VARCHAR(100),
prenom VARCHAR(100),
email VARCHAR(255),
token_reinitialisation VARCHAR(255),
PRIMARY KEY (id),
CONSTRAINT ux_u_login UNIQUE (login),
CONSTRAINT ux_u_email UNIQUE (email)

View File

@ -9,17 +9,14 @@ services:
- "9117:9117"
- "9101:9100"
- "9080:9080"
- "5432:5432"
volumes:
- apache-logs:/var/log/apache2
- postgres-data:/var/lib/postgresql/data
networks:
- centre_observabilite_observability
restart: unless-stopped
volumes:
apache-logs:
postgres-data:
networks:
centre_observabilite_observability: