docker ok
This commit is contained in:
parent
070c26450c
commit
123ea0ba2a
@ -1,12 +1,14 @@
|
||||
# compose project name. A docker compose project has as its name
|
||||
# the name of the folder where it is executed (default).
|
||||
# This setting overrides the default
|
||||
COMPOSE_PROJECT_NAME=gmo-loki
|
||||
COMPOSE_PROJECT_NAME=wwwgmo
|
||||
# must be the same that SITE_VERSION
|
||||
# define in php-fpm/.env
|
||||
DOCKER_IMAGE_VERSION="3.25"
|
||||
# docker image tag = DOCKER_IMAGE_VERSION
|
||||
DOCKER_IMAGE=gmouchet/wwwgmo-php-fpm
|
||||
# docker ports
|
||||
NGINX_PORT=8085
|
||||
PMA_PORT_WEB=8084
|
||||
PMA_PORT_WEB_HTTPS=8084
|
||||
# elastic version
|
||||
ELASTIC_VERSION=8.18.2
|
||||
413
README.md
413
README.md
@ -7,8 +7,11 @@ Examples site with nginx, phpfpm, mysql, phpmyadmin, elasticsearch and kibana
|
||||
|:---|:---|
|
||||
|docker.sh|files to build the docker image|
|
||||
|docker/mariadb|env file|
|
||||
|docker/phpmyadmin|config for phpmyadmin|
|
||||
|docker/nginx|config file|
|
||||
|docker/php-fpm|files to create docker image|
|
||||
|docker/elasticsearch|env file + script for elasticsearch|
|
||||
|docker/kibana|env file|
|
||||
|src|site source|
|
||||
|
||||
## Docker
|
||||
@ -18,10 +21,6 @@ Copy file ALL `.env.dist` to `.env`
|
||||
Complete or modify the values according to your needs
|
||||
|
||||
### Build
|
||||
#### Install plugin php for elasticsearch
|
||||
```bash
|
||||
./docker.sh install
|
||||
```
|
||||
#### Build image
|
||||
```bash
|
||||
./docker.sh build
|
||||
@ -36,18 +35,21 @@ or
|
||||
```
|
||||
#### Check
|
||||
```bash
|
||||
docker exec wwwgmo-mariadb mysql -uroot -p<MYSQL_ROOT_PASSWORD> mysql -e 'SELECT user,host FROM mysql.user;'
|
||||
docker exec <COMPOSE_PROJECT_NAME>-mariadb-1 mysql -uroot -p<MYSQL_ROOT_PASSWORD> mysql -e 'SELECT user,host FROM mysql.user;'
|
||||
```
|
||||
```bash
|
||||
docker exec wwwgmo-elasticsearch curl -u elastic:<ELASTIC_PASSWORD> http://wwwgmo-elasticsearch:9200/_cluster/health?pretty
|
||||
docker exec <COMPOSE_PROJECT_NAME>-elasticsearch-1 curl -u elastic:<ELASTIC_PASSWORD> http://elasticsearch:9200/_cluster/health?pretty
|
||||
```
|
||||
```bash
|
||||
docker exec wwwgmo-php-fpm curl -s -u elastic:<ELASTIC_PASSWORD> http://wwwgmo-elasticsearch:9200/_cluster/health?pretty
|
||||
docker exec <COMPOSE_PROJECT_NAME>-php-fpm-1 curl -u elastic:<ELASTIC_PASSWORD> http://wwwgmo-elasticsearch:9200/_cluster/health?pretty
|
||||
```
|
||||
|
||||
#### Access
|
||||
|
||||
http://<server_name>:<NGINX_PORT>
|
||||
https://<server_name>:<NGINX_PORT>
|
||||
|
||||
|
||||
|
||||
|
||||
## kubernetes
|
||||
|
||||
@ -78,11 +80,11 @@ kubectl create secret docker-registry secret-regcred --dry-run=client \
|
||||
```
|
||||
### Certificats
|
||||
```bash
|
||||
cat certs/gmolab.net.key | base64 -w0
|
||||
cat certs/tls.key | base64 -w0
|
||||
```
|
||||
copy the base64 result into file `values-secrets.yaml` in ssl_key key
|
||||
```bash
|
||||
cat certs/gmolab.net.crt | base64 -w0
|
||||
cat certs/tls.crt | base64 -w0
|
||||
```
|
||||
copy the base64 result into file `values-config.yaml` in ssl_crt key
|
||||
|
||||
@ -215,394 +217,3 @@ https://www.elastic.co/guide/en/elasticsearch/reference/8.18/docker.html
|
||||
|
||||
### 1.0 (2024-03-01)
|
||||
* Created from scratch
|
||||
|
||||
|
||||
|
||||
|
||||
Ignorer et passer au contenu
|
||||
Vous avez dit :
|
||||
J'ai l'erreur suivante lorsque j'exécute mon ficher docker-compose.yml:
|
||||
[2025-06-19T16:58:29.674+00:00][ERROR][elasticsearch-service] Unable to retrieve version information from Elasticsearch nodes. security_exception
|
||||
Root causes:
|
||||
security_exception: missing authentication credentials for REST request [/_nodes?filter_path=nodes.*.version%2Cnodes.*.http.publish_address%2Cnodes.*.ip]
|
||||
|
||||
Mon fichier docker-compose.yml
|
||||
elasticsearch:
|
||||
image: docker.elastic.co/elasticsearch/elasticsearch:8.18.2
|
||||
container_name: elasticsearch
|
||||
environment:
|
||||
- node.name=es01
|
||||
- cluster.name=es-docker-cluster
|
||||
- discovery.type=single-node
|
||||
- bootstrap.memory_lock=true
|
||||
- xpack.security.enabled=true
|
||||
- ELASTIC_PASSWORD=changeme
|
||||
- xpack.security.http.ssl.enabled=false
|
||||
- ES_JAVA_OPTS=-Xms1g -Xmx1g
|
||||
ulimits:
|
||||
memlock:
|
||||
soft: -1
|
||||
hard: -1
|
||||
ports:
|
||||
- "9200:9200"
|
||||
- "9300:9300"
|
||||
volumes:
|
||||
# - esdata:/usr/share/elasticsearch/data
|
||||
- wwwgmo-elasticsearch:/usr/share/elasticsearch/data
|
||||
|
||||
kibana:
|
||||
image: docker.elastic.co/kibana/kibana:8.18.2
|
||||
container_name: kibana
|
||||
depends_on:
|
||||
- elasticsearch
|
||||
environment:
|
||||
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
|
||||
- xpack.security.enabled=false
|
||||
ports:
|
||||
- "5601:5601"
|
||||
ChatGPT a dit :
|
||||
L’erreur que vous rencontrez est causée par l’activation de la sécurité dans Elasticsearch (xpack.security.enabled=true) sans fournir d’identifiants d’authentification lors de la tentative d’accès à l'API REST.
|
||||
|
||||
🔍 Détail de l'erreur :
|
||||
security_exception: missing authentication credentials for REST request [/_nodes?...]
|
||||
Cela signifie que Kibana ou un autre service tente de communiquer avec Elasticsearch sans credentials, alors que ce dernier requiert une authentification.
|
||||
|
||||
✅ Solution 1 : Aligner la sécurité entre Kibana et Elasticsearch
|
||||
|
||||
Actuellement :
|
||||
|
||||
Elasticsearch a xpack.security.enabled=true
|
||||
Kibana a xpack.security.enabled=false
|
||||
Ce n’est pas compatible. Kibana doit être configuré pour utiliser les identifiants quand Elasticsearch a la sécurité activée.
|
||||
|
||||
🛠 Modifier la section kibana comme suit :
|
||||
kibana:
|
||||
image: docker.elastic.co/kibana/kibana:8.18.2
|
||||
container_name: kibana
|
||||
depends_on:
|
||||
- elasticsearch
|
||||
environment:
|
||||
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
|
||||
- ELASTICSEARCH_USERNAME=elastic
|
||||
- ELASTICSEARCH_PASSWORD=changeme
|
||||
ports:
|
||||
- "5601:5601"
|
||||
⚠️ Important : On utilise ici ELASTICSEARCH_USERNAME=elastic et ELASTICSEARCH_PASSWORD=changeme, car vous avez défini ce mot de passe dans la variable d'environnement ELASTIC_PASSWORD côté Elasticsearch.
|
||||
✅ Solution 2 : Désactiver complètement la sécurité (pour développement uniquement)
|
||||
|
||||
Si vous êtes en environnement de test ou de développement local, vous pouvez désactiver la sécurité côté Elasticsearch.
|
||||
|
||||
environment:
|
||||
- xpack.security.enabled=false
|
||||
Dans ce cas, gardez aussi Kibana sans sécurité :
|
||||
|
||||
- xpack.security.enabled=false
|
||||
⚠️ Pas recommandé en production : cette approche désactive les protections d’accès aux données.
|
||||
🧪 Astuce : Tester si tout fonctionne
|
||||
Une fois les containers relancés, testez l’accès à Elasticsearch :
|
||||
|
||||
curl -u elastic:changeme http://localhost:9200
|
||||
Et pour Kibana : ouvrez http://localhost:5601 dans un navigateur.
|
||||
|
||||
Souhaitez-vous :
|
||||
|
||||
Garder la sécurité activée et intégrer les credentials dans tous les services ?
|
||||
Ou désactiver la sécurité pour un usage local plus simple ?
|
||||
Vous avez dit :
|
||||
Garder la sécurité activée et intégrer les credentials dans tous les services
|
||||
ChatGPT a dit :
|
||||
Parfait ! Si vous souhaitez garder la sécurité activée, alors il faut que tous les services clients (comme Kibana) s’authentifient auprès d’Elasticsearch.
|
||||
|
||||
Voici comment ajuster correctement votre docker-compose.yml pour intégrer les identifiants.
|
||||
|
||||
✅ Fichier docker-compose.yml corrigé
|
||||
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
elasticsearch:
|
||||
image: docker.elastic.co/elasticsearch/elasticsearch:8.18.2
|
||||
container_name: elasticsearch
|
||||
environment:
|
||||
- node.name=es01
|
||||
- cluster.name=es-docker-cluster
|
||||
- discovery.type=single-node
|
||||
- bootstrap.memory_lock=true
|
||||
- xpack.security.enabled=true
|
||||
- xpack.security.http.ssl.enabled=false
|
||||
- ELASTIC_PASSWORD=changeme
|
||||
- ES_JAVA_OPTS=-Xms1g -Xmx1g
|
||||
ulimits:
|
||||
memlock:
|
||||
soft: -1
|
||||
hard: -1
|
||||
ports:
|
||||
- "9200:9200"
|
||||
- "9300:9300"
|
||||
volumes:
|
||||
- wwwgmo-elasticsearch:/usr/share/elasticsearch/data
|
||||
|
||||
kibana:
|
||||
image: docker.elastic.co/kibana/kibana:8.18.2
|
||||
container_name: kibana
|
||||
depends_on:
|
||||
- elasticsearch
|
||||
environment:
|
||||
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
|
||||
- ELASTICSEARCH_USERNAME=elastic
|
||||
- ELASTICSEARCH_PASSWORD=changeme
|
||||
ports:
|
||||
- "5601:5601"
|
||||
|
||||
volumes:
|
||||
wwwgmo-elasticsearch:
|
||||
🔐 Authentification à l'API Elasticsearch (test via curl)
|
||||
|
||||
Une fois vos conteneurs démarrés, testez si l'accès avec mot de passe fonctionne :
|
||||
|
||||
curl -u elastic:changeme http://localhost:9200
|
||||
Réponse attendue :
|
||||
|
||||
{
|
||||
"name": "es01",
|
||||
"cluster_name": "es-docker-cluster",
|
||||
"cluster_uuid": "...",
|
||||
"version": {
|
||||
"number": "8.18.2",
|
||||
...
|
||||
},
|
||||
"tagline": "You Know, for Search"
|
||||
}
|
||||
✅ Accès à Kibana
|
||||
|
||||
Ouvrez http://localhost:5601 dans votre navigateur. Kibana devrait démarrer sans vous afficher d'erreur liée à la connexion Elasticsearch.
|
||||
|
||||
✅ Recommandation de sécurité (optionnelle)
|
||||
|
||||
Pour un environnement plus sûr :
|
||||
|
||||
Créez un nouvel utilisateur avec des permissions spécifiques pour Kibana, via l’API ou l’interface d’admin de Kibana.
|
||||
Évitez d'utiliser elastic en production, car c’est un super admin.
|
||||
Souhaitez-vous un exemple de script pour créer un utilisateur avec rôle personnalisé ?
|
||||
|
||||
Vous avez dit :
|
||||
Error: [config validation of [elasticsearch].username]: value of "elastic" is forbidden. This is a superuser account that cannot write to system indices that Kibana needs to function. Use a service account token instead. Learn more: https://www.elastic.co/guide/en/elasticsearch/reference/8.0/service-accounts.html
|
||||
at ensureValidConfiguration (/usr/share/kibana/node_modules/@kbn/core-config-server-internal/src/ensure_valid_configuration.js:44:11)
|
||||
at Server.preboot (/usr/share/kibana/node_modules/@kbn/core-root-server-internal/src/server.js:181:7)
|
||||
at Root.preboot (/usr/share/kibana/node_modules/@kbn/core-root-server-internal/src/root/index.js:48:14)
|
||||
at bootstrap (/usr/share/kibana/node_modules/@kbn/core-root-server-internal/src/bootstrap.js:96:29)
|
||||
at Command.<anonymous> (/usr/share/kibana/src/cli/serve/serve.js:235:5)
|
||||
ChatGPT a dit :
|
||||
Merci pour ce message d’erreur très clair — Kibana refuse catégoriquement d'utiliser l'utilisateur elastic à partir d'Elasticsearch 8, car :
|
||||
|
||||
❌ elastic est un super-utilisateur. Il ne peut pas être utilisé pour que Kibana écrive dans les indices système, ce qui est nécessaire pour qu'il fonctionne correctement.
|
||||
✅ Solution recommandée : utiliser un service account token
|
||||
|
||||
🔐 Étapes pour créer un Service Account Token pour Kibana :
|
||||
Lancer Elasticsearch avec sécurité activée
|
||||
Gardez xpack.security.enabled=true
|
||||
Assurez-vous que le conteneur Elasticsearch fonctionne
|
||||
Créer un Service Account Token pour Kibana
|
||||
Ouvrez un terminal et exécutez :
|
||||
docker exec -it elasticsearch \
|
||||
bin/elasticsearch-service-tokens create kibana kibana-token
|
||||
Cela génère un token dans ce format :
|
||||
AAEAAWVsYXN0aWMvY2liYW5hL2tpYmFuYS10b2tlbjoxR3VOSVZzUjZsb3pk...
|
||||
Mettre à jour votre docker-compose.yml pour Kibana
|
||||
Supprimez ELASTICSEARCH_USERNAME et ELASTICSEARCH_PASSWORD, et utilisez ELASTICSEARCH_SERVICEACCOUNTTOKEN à la place :
|
||||
|
||||
kibana:
|
||||
image: docker.elastic.co/kibana/kibana:8.18.2
|
||||
container_name: kibana
|
||||
depends_on:
|
||||
- elasticsearch
|
||||
environment:
|
||||
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
|
||||
- ELASTICSEARCH_SERVICEACCOUNTTOKEN=AAEAAWVsYXN0aWMvY2liYW5hL2tpYmFuYS10b2tlbjoxR3VOSVZzUjZsb3pk...
|
||||
ports:
|
||||
- "5601:5601"
|
||||
(remplace le token par celui généré précédemment)
|
||||
🔄 Ensuite :
|
||||
|
||||
Redémarre les services :
|
||||
docker-compose down
|
||||
docker-compose up -d
|
||||
Va sur http://localhost:5601 pour voir Kibana se connecter correctement.
|
||||
🔎 Besoin d'aller plus loin ?
|
||||
|
||||
Si tu préfères créer un utilisateur dédié à Kibana au lieu d’un token de service, je peux aussi te guider pas à pas avec elasticsearch-users ou via l'API REST.
|
||||
|
||||
Souhaites-tu cette alternative ?
|
||||
|
||||
Vous avez dit :
|
||||
oui
|
||||
ChatGPT a dit :
|
||||
Parfait ! Voici comment créer un utilisateur dédié à Kibana, via l'API REST d'Elasticsearch, avec des rôles appropriés pour permettre à Kibana de fonctionner sans utiliser le super-utilisateur elastic.
|
||||
|
||||
🎯 Objectif
|
||||
|
||||
Créer un utilisateur, par exemple kibana_system_user, qui a le rôle kibana_system (prérequis minimum pour que Kibana fonctionne).
|
||||
|
||||
✅ Étapes détaillées
|
||||
|
||||
1. 🔐 Authentifiez-vous avec le super-utilisateur elastic
|
||||
Exécute cette commande pour vérifier que tu peux parler à Elasticsearch :
|
||||
|
||||
curl -u elastic:changeme http://localhost:9200
|
||||
2. 👤 Créer un nouvel utilisateur kibana_system_user
|
||||
curl -X POST http://localhost:9200/_security/user/kibana_system_user \
|
||||
-u elastic:changeme \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"password" : "kibanapassword",
|
||||
"roles" : [ "kibana_system" ],
|
||||
"full_name" : "Kibana System User",
|
||||
"email" : "kibana@example.com"
|
||||
}'
|
||||
⚠️ Le mot de passe ici est kibanapassword. Tu peux le changer selon tes préférences.
|
||||
|
||||
3. 🔧 Modifier docker-compose.yml pour Kibana
|
||||
Mets à jour la section Kibana avec ces variables d’environnement :
|
||||
|
||||
kibana:
|
||||
image: docker.elastic.co/kibana/kibana:8.18.2
|
||||
container_name: kibana
|
||||
depends_on:
|
||||
- elasticsearch
|
||||
environment:
|
||||
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
|
||||
- ELASTICSEARCH_USERNAME=kibana_system_user
|
||||
- ELASTICSEARCH_PASSWORD=kibanapassword
|
||||
ports:
|
||||
- "5601:5601"
|
||||
4. 🔄 Redémarre les services
|
||||
docker-compose down
|
||||
docker-compose up -d
|
||||
5. ✅ Accès à Kibana
|
||||
Rends-toi sur http://localhost:5601. Kibana devrait démarrer sans erreur de permission, car il utilise désormais un utilisateur restreint, mais autorisé à accéder aux indices système nécessaires.
|
||||
|
||||
✅ Résumé
|
||||
|
||||
Élément Valeur
|
||||
Utilisateur Elasticsearch kibana_system_user
|
||||
Rôle attribué kibana_system
|
||||
Mot de passe kibanapassword (ou autre)
|
||||
Avantage Bonne pratique, sécurisé
|
||||
Souhaites-tu aussi créer un utilisateur pour ingester des données dans Elasticsearch via une application ?
|
||||
|
||||
Vous avez dit :
|
||||
et tout ca dans un fichier docker-compose
|
||||
ChatGPT a dit :
|
||||
Parfait, je vais t’aider à tout intégrer dans un seul docker-compose.yml, avec :
|
||||
|
||||
Elasticsearch sécurisé
|
||||
Création automatique de l’utilisateur kibana_system_user avec le rôle kibana_system
|
||||
Kibana configuré pour utiliser cet utilisateur
|
||||
⚠️ Important :
|
||||
Elasticsearch ne permet pas nativement la création d'utilisateurs via le docker-compose.yml, donc on doit ajouter un script d'initialisation personnalisé monté dans le conteneur, qui s'exécute au démarrage.
|
||||
|
||||
✅ Structure du projet recommandée :
|
||||
|
||||
project/
|
||||
├── docker-compose.yml
|
||||
├── elasticsearch/
|
||||
│ └── create_kibana_user.sh
|
||||
🔧 elasticsearch/create_kibana_user.sh (script d'init)
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
# Attendre qu'Elasticsearch soit démarré
|
||||
echo "⏳ Attente du démarrage d'Elasticsearch..."
|
||||
until curl -u elastic:changeme -s http://localhost:9200 >/dev/null; do
|
||||
sleep 2
|
||||
done
|
||||
|
||||
echo "✅ Elasticsearch est prêt. Création de l'utilisateur Kibana..."
|
||||
|
||||
# Créer un utilisateur pour Kibana
|
||||
curl -X POST http://localhost:9200/_security/user/kibana_system_user \
|
||||
-u elastic:changeme \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"password" : "kibanapassword",
|
||||
"roles" : [ "kibana_system" ],
|
||||
"full_name" : "Kibana System User"
|
||||
}'
|
||||
|
||||
echo "✅ Utilisateur Kibana créé avec succès."
|
||||
Donne les permissions au script :
|
||||
chmod +x elasticsearch/create_kibana_user.sh
|
||||
📦 docker-compose.yml complet
|
||||
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
elasticsearch:
|
||||
image: docker.elastic.co/elasticsearch/elasticsearch:8.18.2
|
||||
container_name: elasticsearch
|
||||
environment:
|
||||
- node.name=es01
|
||||
- cluster.name=es-docker-cluster
|
||||
- discovery.type=single-node
|
||||
- bootstrap.memory_lock=true
|
||||
- xpack.security.enabled=true
|
||||
- xpack.security.http.ssl.enabled=false
|
||||
- ELASTIC_PASSWORD=changeme
|
||||
- ES_JAVA_OPTS=-Xms1g -Xmx1g
|
||||
ulimits:
|
||||
memlock:
|
||||
soft: -1
|
||||
hard: -1
|
||||
ports:
|
||||
- "9200:9200"
|
||||
- "9300:9300"
|
||||
volumes:
|
||||
- wwwgmo-elasticsearch:/usr/share/elasticsearch/data
|
||||
- ./elasticsearch/create_kibana_user.sh:/usr/local/bin/create_kibana_user.sh
|
||||
command: >
|
||||
bash -c "
|
||||
/bin/tini -g -- /usr/local/bin/docker-entrypoint.sh &
|
||||
pid=$!;
|
||||
sleep 20;
|
||||
bash /usr/local/bin/create_kibana_user.sh;
|
||||
wait $pid
|
||||
"
|
||||
|
||||
kibana:
|
||||
image: docker.elastic.co/kibana/kibana:8.18.2
|
||||
container_name: kibana
|
||||
depends_on:
|
||||
- elasticsearch
|
||||
environment:
|
||||
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
|
||||
- ELASTICSEARCH_USERNAME=kibana_system_user
|
||||
- ELASTICSEARCH_PASSWORD=kibanapassword
|
||||
ports:
|
||||
- "5601:5601"
|
||||
|
||||
volumes:
|
||||
wwwgmo-elasticsearch:
|
||||
✅ Lancer le tout
|
||||
|
||||
Dans ton terminal :
|
||||
|
||||
docker-compose down -v
|
||||
docker-compose up --build
|
||||
✅ Résultat attendu
|
||||
|
||||
Elasticsearch démarre avec la sécurité activée
|
||||
Un script crée automatiquement un utilisateur kibana_system_user
|
||||
Kibana l'utilise pour se connecter
|
||||
Tout est prêt et fonctionnel sans intervention manuelle
|
||||
Souhaites-tu que je t’aide à ajouter aussi un utilisateur applicatif (ex: my_app_user) avec accès en lecture/écriture ?
|
||||
|
||||
|
||||
|
||||
|
||||
Joindre
|
||||
|
||||
Rechercher
|
||||
|
||||
Voix
|
||||
|
||||
ChatGPT peut faire des erreurs. Envisagez de vérifier les informations importantes.
|
||||
|
||||
@ -1,23 +1,23 @@
|
||||
services:
|
||||
# Linux nginx mysql php
|
||||
# server http nginx
|
||||
#--------------------------------------
|
||||
# service http nginx
|
||||
#--------------------------------------
|
||||
nginx:
|
||||
# container_name: wwwgmo-nginx
|
||||
# hostname: wwwgmo-nginx
|
||||
image: nginxinc/nginx-unprivileged:1.23-alpine
|
||||
volumes:
|
||||
- './docker/nginx/default.conf:/etc/nginx/conf.d/default.conf'
|
||||
- './certs:/etc/nginx/certs/'
|
||||
- './src:/var/www/html:rw,cached'
|
||||
ports:
|
||||
- '${NGINX_PORT}:8080' #local:docker
|
||||
# depends_on:
|
||||
# - wwwgmo-php-fpm
|
||||
##
|
||||
#- '${NGINX_PORT}:8080'
|
||||
- '${NGINX_PORT}:8443'
|
||||
depends_on:
|
||||
- php-fpm
|
||||
#--------------------------------------
|
||||
# service php-fpm
|
||||
#--------------------------------------
|
||||
php-fpm:
|
||||
# container_name: wwwgmo-php-fpm
|
||||
# hostname: wwwgmo-php-fpm
|
||||
# #image: wwwgmo
|
||||
image: ${DOCKER_IMAGE}:${DOCKER_IMAGE_VERSION}
|
||||
env_file:
|
||||
- ./docker/php-fpm/.env
|
||||
@ -27,33 +27,42 @@ services:
|
||||
context: .
|
||||
dockerfile: ./docker/php-fpm/Dockerfile
|
||||
ports:
|
||||
- '9000:9000' #local:docker
|
||||
- '9000:9000'
|
||||
depends_on:
|
||||
- mariadb
|
||||
|
||||
#--------------------------------------
|
||||
# service mariadb
|
||||
#--------------------------------------
|
||||
mariadb:
|
||||
# container_name: wwwgmo-mariadb
|
||||
# hostname: wwwgmo-mariadb
|
||||
#image: mysql:8.0-debian
|
||||
#image: mysql/mysql-server:8.0.27-aarch64
|
||||
image: mariadb:10.11.7
|
||||
volumes:
|
||||
- 'wwwgmo-mariadb:/var/lib/mysql:z'
|
||||
- 'mariadb:/var/lib/mysql:z'
|
||||
env_file:
|
||||
- ./docker/mariadb/.env # ports:
|
||||
|
||||
- ./docker/mariadb/.env
|
||||
#--------------------------------------
|
||||
# service phpmyadmin
|
||||
#--------------------------------------
|
||||
phpmyadmin:
|
||||
# container_name: wwwgmo-pma
|
||||
image: phpmyadmin
|
||||
volumes:
|
||||
- ./certs:/etc/apache2/ssl
|
||||
- ./docker/phpmyadmin/apache-ssl.conf:/etc/apache2/sites-available/default-ssl.conf
|
||||
- ./docker/phpmyadmin/config.secret.inc.php:/etc/phpmyadmin/config.secret.inc.php
|
||||
links:
|
||||
- mariadb
|
||||
env_file:
|
||||
- ./docker/mariadb/.env
|
||||
restart: always
|
||||
ports:
|
||||
- ${PMA_PORT_WEB}:80
|
||||
#
|
||||
# elasticsearch
|
||||
- ${PMA_PORT_WEB_HTTPS}:443
|
||||
command: >
|
||||
sh -c "a2enmod ssl &&
|
||||
a2ensite default-ssl &&
|
||||
apache2-foreground"
|
||||
|
||||
#--------------------------------------
|
||||
# service elasticsearch
|
||||
#--------------------------------------
|
||||
elasticsearch:
|
||||
image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTIC_VERSION}
|
||||
#container_name: elasticsearch
|
||||
@ -67,7 +76,7 @@ services:
|
||||
- "9200:9200"
|
||||
- "9300:9300"
|
||||
volumes:
|
||||
- wwwgmo-elasticsearch:/usr/share/elasticsearch/data
|
||||
- elasticsearch:/usr/share/elasticsearch/data
|
||||
- ./docker/elasticsearch/create_kibana_user.sh:/usr/local/bin/create_kibana_user.sh
|
||||
command: >
|
||||
bash -c "
|
||||
@ -77,19 +86,20 @@ services:
|
||||
bash /usr/local/bin/create_kibana_user.sh;
|
||||
wait $pid
|
||||
"
|
||||
# kibana
|
||||
#--------------------------------------
|
||||
# service kibana
|
||||
#--------------------------------------
|
||||
kibana:
|
||||
image: docker.elastic.co/kibana/kibana:${ELASTIC_VERSION}
|
||||
#container_name: kibana
|
||||
env_file:
|
||||
- ./docker/kibana/.env
|
||||
volumes:
|
||||
- './certs:/usr/share/kibana/config/certs/'
|
||||
depends_on:
|
||||
- elasticsearch
|
||||
ports:
|
||||
- "5601:5601"
|
||||
|
||||
volumes:
|
||||
wwwgmo-elasticsearch:
|
||||
name: elasticsearch
|
||||
wwwgmo-mariadb:
|
||||
name: mariadb
|
||||
elasticsearch:
|
||||
mariadb:
|
||||
|
||||
32
docker.sh
32
docker.sh
@ -14,22 +14,19 @@ fi
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
install)
|
||||
env UID=${_UID} GID=${_GID} docker compose up -d php-fpm
|
||||
#docker exec --user root wwwgmo-php-fpm "/bin/sh -c 'cd /var/www/html/; composer require elasticsearch/elasticsearch'"
|
||||
#docker exec --user root ${COMPOSE_PROJECT_NAME}-php-fpm-1 /bin/sh -c "cd /var/www/html; composer require elasticsearch/elasticsearch:^7.17.2"
|
||||
docker exec --user root ${COMPOSE_PROJECT_NAME}-php-fpm-1 /bin/sh -c "cd /var/www/html; composer require elasticsearch/elasticsearch:^8.0"
|
||||
env UID=${_UID} GID=${_GID} docker compose stop
|
||||
;;
|
||||
# install)
|
||||
# env UID=${_UID} GID=${_GID} docker compose up -d php-fpm
|
||||
# docker exec --user root ${COMPOSE_PROJECT_NAME}-php-fpm-1 /bin/sh -c "cd /var/www/html; composer require elasticsearch/elasticsearch"
|
||||
# env UID=${_UID} GID=${_GID} docker compose stop
|
||||
# ;;
|
||||
start)
|
||||
sudo chown -R $_UID:$_GID ./certs/
|
||||
env UID=${_UID} GID=${_GID} docker compose up -d;
|
||||
docker exec --user root ${COMPOSE_PROJECT_NAME}-php-fpm-1 composer install --no-interaction
|
||||
;;
|
||||
start-nginx)
|
||||
env UID=${_UID} GID=${_GID} docker compose up -d wwwgmo-nginx
|
||||
;;
|
||||
start-db)
|
||||
env UID=${_UID} GID=${_GID} docker compose up -d wwwgmo-mariadb
|
||||
restart)
|
||||
sudo chown -R $_UID:$_GID ./certs/
|
||||
docker compose down --remove-orphans
|
||||
env UID=${_UID} GID=${_GID} docker compose up -d;
|
||||
;;
|
||||
stop)
|
||||
env UID=${_UID} GID=${_GID} docker compose stop
|
||||
@ -48,6 +45,8 @@ do
|
||||
sudo chown -R $_UID:$_GID ./src/
|
||||
env UID=${_UID} GID=${_GID} docker compose build --pull --no-cache
|
||||
env UID=${_UID} GID=${_GID} docker compose up -d;
|
||||
# install lasticsearch client for PHP
|
||||
docker exec --user root ${COMPOSE_PROJECT_NAME}-php-fpm-1 /bin/sh -c "cd /var/www/html; composer require elasticsearch/elasticsearch"
|
||||
#docker exec --user root wwwgmo-php-fpm composer install --no-interaction
|
||||
sleep 5 # wait mysql container up
|
||||
#docker exec -it wwwgmo-mariadb /bin/bash -c "mysql -u root --password=password -e \
|
||||
@ -61,6 +60,8 @@ do
|
||||
sudo chown -R $_UID:$_GID ./src/
|
||||
env UID=${_UID} GID=${_GID} docker compose build
|
||||
env UID=${_UID} GID=${_GID} docker compose up -d;
|
||||
# install lasticsearch client for PHP
|
||||
docker exec --user root ${COMPOSE_PROJECT_NAME}-php-fpm-1 /bin/sh -c "cd /var/www/html; composer require elasticsearch/elasticsearch"
|
||||
#docker exec --user root wwwgmo-php-fpm composer install --no-interaction
|
||||
#sleep 5 # wait mysql container up
|
||||
#docker exec -it wwwgmo-mysql /bin/bash -c "mysql -u root --password=password -e \
|
||||
@ -72,8 +73,11 @@ do
|
||||
push)
|
||||
docker image push ${DOCKER_IMAGE}:${DOCKER_IMAGE_VERSION}
|
||||
;;
|
||||
down)
|
||||
docker compose down --remove-orphans
|
||||
;;
|
||||
*)
|
||||
echo "docker.sh [start|stop|install|logs|bash-root|bash|build|build-no-cache|push]"
|
||||
echo "docker.sh [start|stop||logs|bash-root|bash|build|build-no-cache|push|down]"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
# config es
|
||||
node.name=es01
|
||||
cluster.name=es-docker-cluster
|
||||
cluster.name=es-cluster
|
||||
discovery.type=single-node
|
||||
bootstrap.memory_lock=true
|
||||
xpack.security.enabled=true
|
||||
xpack.security.http.ssl.enabled=false
|
||||
ES_JAVA_OPTS=-Xms1g -Xmx1g
|
||||
# password for elasric use
|
||||
# password for elastic user
|
||||
ELASTIC_PASSWORD=pa55w0rd
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
!/bin/bash
|
||||
|
||||
# create a user on es to allow kibana to connect to es
|
||||
# from es 8 kibana cannot connect with elastic user.
|
||||
# elastic user can be use to login form kibana UI
|
||||
# Wait for elasticsearch to start
|
||||
echo "--- waiting for elasticsearch to start..."
|
||||
until curl -u elastic:${ELASTIC_PASSWORD} -s http://localhost:9200 >/dev/null; do
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
# es url
|
||||
ELASTICSEARCH_HOSTS=http://elasticsearch:9200
|
||||
# username (technical) with which kibana connects to elasticsearch
|
||||
# username (technical) with kibana connects to elasticsearch
|
||||
# the username is create with docker/elasticsearch/create_kibana_user.sh
|
||||
# script
|
||||
ELASTICSEARCH_USERNAME=kibana_system_user
|
||||
# password for username
|
||||
ELASTICSEARCH_PASSWORD=kibanapassword
|
||||
|
||||
@ -6,7 +6,7 @@ MYSQL_USER=wwwgmo
|
||||
MYSQL_PASSWORD=password
|
||||
MYSQL_TCP_PORT=3306
|
||||
# phpmyadmin
|
||||
PMA_HOST=wwwgmo-mariadb
|
||||
PMA_HOST=mariadb
|
||||
PMA_USER=root
|
||||
PMA_PASSWORD=pa55w0rd
|
||||
PMA_PORT=3306
|
||||
|
||||
@ -17,10 +17,17 @@
|
||||
#add_header Referrer-Policy "origin-when-cross-origin" always;
|
||||
#add_header Strict-Transport-Security "max-age=31536000" always;
|
||||
|
||||
server {
|
||||
listen 8080 default_server;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
index index.php;
|
||||
root /var/www/html;
|
||||
listen 8080;
|
||||
listen 8443 ssl;
|
||||
ssl_certificate /etc/nginx/certs/tls.crt;
|
||||
ssl_certificate_key /etc/nginx/certs/tls.key;
|
||||
server_name _;
|
||||
error_log /dev/stderr;
|
||||
access_log /dev/stdout;
|
||||
|
||||
@ -1,22 +1,24 @@
|
||||
# site
|
||||
SITE_TITLE="Stack GMo - PHP-FPM - MariaDB - Elasticsearch"
|
||||
# must be the same that DOCKER_IMAGE_VERSION define in .env
|
||||
SITE_VERSION="3.25"
|
||||
#SITE_VERSION="3.25-arm64"
|
||||
SITE_VERSION=${DOCKER_IMAGE_VERSION}
|
||||
# db
|
||||
DB_NAME=wwwgmo
|
||||
DB_USER=wwwgmo
|
||||
DB_PASSWORD=password
|
||||
DB_HOST=wwwgmo-mariadb
|
||||
DB_HOST=mariadb
|
||||
DB_PORT=3306
|
||||
DB_TABLE=tbl_email
|
||||
# PMA
|
||||
# the port must be the same as PMA_PORT_WEB define in .env on root project path
|
||||
PMA_URL=http://gmoadm.gmolab.net:8084
|
||||
KIBANA_URL=http://gmoadm.gmolab.net:5601
|
||||
PMA_URL=https://docker1.gmolab.net:8084
|
||||
KIBANA_URL=https://docker1.gmolab.net:5601
|
||||
# Elsaticsearch/kibana
|
||||
ES_HOST=wwwgmo-elasticsearch:9200
|
||||
ES_HOST=elasticsearch:9200
|
||||
ES_USER=elastic
|
||||
ES_PASSWORD=pa55w0rd
|
||||
ES_INDEX=wwwgmo_index
|
||||
KIB_PORT=5601
|
||||
|
||||
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
#https://hub.docker.com/r/rhamdeew/docker-php-8-fpm-alpine/dockerfile
|
||||
#https://github.com/elastic/elasticsearch-php
|
||||
|
||||
FROM php:8.2.6-fpm-alpine
|
||||
#FROM php:8.2.6-fpm-alpine
|
||||
FROM php:8.4-fpm-alpine3.22
|
||||
LABEL maintainer="gilles.mouchet@gmail.com"
|
||||
|
||||
RUN apk add --no-cache mysql-client msmtp perl wget procps shadow libzip libpng libjpeg-turbo libwebp freetype icu
|
||||
|
||||
13
docker/phpmyadmin/apache-ssl.conf
Normal file
13
docker/phpmyadmin/apache-ssl.conf
Normal file
@ -0,0 +1,13 @@
|
||||
<IfModule mod_ssl.c>
|
||||
<VirtualHost _default_:443>
|
||||
ServerAdmin webmaster@localhost
|
||||
DocumentRoot /var/www/html
|
||||
|
||||
SSLEngine on
|
||||
SSLCertificateFile /etc/apache2/ssl/tls.crt
|
||||
SSLCertificateKeyFile /etc/apache2/ssl/tls.key
|
||||
|
||||
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||
</VirtualHost>
|
||||
</IfModule>
|
||||
2
docker/phpmyadmin/config.secret.inc.php
Normal file
2
docker/phpmyadmin/config.secret.inc.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
$cfg['blowfish_secret'] = 'UseASuperSecureLongRandomStringHere1234567890!';
|
||||
@ -5,7 +5,7 @@
|
||||
# elasticsearch
|
||||
elastic:
|
||||
priorityClassName: system-cluster-critical
|
||||
imageTag: 7.17.16
|
||||
imageTag: 8.18.2
|
||||
persistentVolumeClaim:
|
||||
#storageRequest: 1Gi
|
||||
storageRequest: 500M
|
||||
@ -77,6 +77,7 @@ site:
|
||||
|
||||
phpfpmSite:
|
||||
repository: gmouchet/wwwgmo-php-fpm
|
||||
imageTag:
|
||||
pullPolicy: Always
|
||||
ressourceRequest:
|
||||
memory: 16M #16 Mo RAM
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"require": {
|
||||
"elasticsearch/elasticsearch": "^8.0"
|
||||
"elasticsearch/elasticsearch": "^8.18"
|
||||
}
|
||||
}
|
||||
|
||||
2
src/composer.lock
generated
2
src/composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "896ff89adf34fedde1ecec1943b40744",
|
||||
"content-hash": "9ed50e8752b44f2433986b7a2af1554b",
|
||||
"packages": [
|
||||
{
|
||||
"name": "elastic/transport",
|
||||
|
||||
@ -34,10 +34,32 @@ curl_close($curl);
|
||||
// decode
|
||||
$array = json_decode($status, true);
|
||||
|
||||
# get version of elasticsearch php composer
|
||||
$composerLockPath = __DIR__ . '/composer.lock';
|
||||
if (!file_exists($composerLockPath)) {
|
||||
die("The composer.lock file was not found.\n");
|
||||
}
|
||||
$composerLock = json_decode(file_get_contents($composerLockPath), true);
|
||||
foreach ($composerLock['packages'] as $package) {
|
||||
if (strpos($package['name'], 'elasticsearch') !== false) {
|
||||
$phpPackName=$package['name'];
|
||||
$phpPackVersion=$package['version'];
|
||||
}
|
||||
}
|
||||
# check if package is installed
|
||||
if (empty($phpPackName)) {
|
||||
$phpPackName="not installed";
|
||||
$phpPackVersion="not installed";
|
||||
}
|
||||
|
||||
// display result
|
||||
echo "<h4>Informations</h4>";
|
||||
echo "<p><b>Name:</b> ".$response['name']."<br>";
|
||||
echo "<h3>Informations</h3>";
|
||||
echo "<h4>Elasticsearch cluster</h4>";
|
||||
echo "<p><b>Node name:</b> ".$response['name']."<br>";
|
||||
echo "<b>Cluster name:</b> ".$response['cluster_name']."<br>";
|
||||
echo "<b>Elasticsearch version:</b> ".$response['version']['number']."<br>";
|
||||
echo "<b>Cluster health status:</b> ".$array['status']."</p>";
|
||||
echo "<h4>Elasticsearch client for PHP</h4>";
|
||||
echo "<p><b>Package name:</b> ".$phpPackName."<br>";
|
||||
echo "<b>Package version:</b> ".$phpPackVersion."</p>";
|
||||
?>
|
||||
Loading…
x
Reference in New Issue
Block a user