-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FONCTIONNEL : Utilisation de docker-compose-support sur un container …
…build . pour développer en local sans application.properties et sans SGBD local.
- Loading branch information
jvk
committed
Mar 29, 2024
1 parent
5b5964c
commit 5272600
Showing
7 changed files
with
48 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,25 @@ | ||
version: '3.8' | ||
version: '3' | ||
services: | ||
app: | ||
image: jeromev34/corbeaudocker:latest | ||
environment: | ||
SPRING_DATASOURCE_URL: jdbc:mysql://localhost:3306/jpa?useSSL=false&serverTimezone=UTC | ||
SPRING_DATASOURCE_USERNAME: root | ||
SPRING_DATASOURCE_PASSWORD: Zp3pbrya | ||
image: myspringbootapp:latest | ||
build: . | ||
extra_hosts: | ||
- "host.docker.internal:host-gateway" | ||
ports: | ||
- "8081:8080" | ||
- "8085:8080" | ||
depends_on: | ||
- db_container | ||
db_container: | ||
image: mysql:8.0 | ||
- db | ||
db: | ||
image: postgres:latest | ||
environment: | ||
MYSQL_DATABASE: 'jpa' | ||
MYSQL_USER: root | ||
MYSQL_PASSWORD: Zp3pbrya | ||
MYSQL_ROOT_PASSWORD: Zp3pbrya | ||
POSTGRES_USER: root | ||
POSTGRES_PASSWORD: Bacille | ||
volumes: | ||
- db-data:/var/lib/mysql | ||
- ./init.sql:/docker-entrypoint-initdb.d/init.sql | ||
ports: | ||
- "3307:3306" | ||
- "5432:5432" | ||
adminer: | ||
image: adminer | ||
restart: always | ||
ports: | ||
- "8082:8080" | ||
|
||
volumes: | ||
db-data: |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
1. Suppression de l'ensemble des fichiers application.properties. | ||
2. Creation des containers : contaier app principal basé sur le build de l'application, base de donnée embarquée, dans un second container, adminer pour administration des données | ||
3. Utilisation de la dépendance spring docker-compose-support | ||
4. Lien de montage entre un script local init.sql qui va initialiser des données dans le base de donnée conteneurisée | ||
5. Adaptation de la SauterelleDao pour prendre en compte postgresql et une nouvelle chaine de connection en localhost qui pourra se connecter a la base de donnée du container (remarque : lu'rl peut etre exploitée dans un client sql comme dbeaver) | ||
6. Lancement de l'application en local qui automatiquement exploitera les containers au lieu d'une compilatio locale de l'application. | ||
|
||
Remarque : ici on utilise un context local avec la variable build dans le container app, mais il aurait trés bien été possible de se brancher sur une image distante qui aurait contenu une base de donnée distante ou un build . local contenurisé qui aurait utilisé une bdd avec SPRING_DATASOURCE_URL | ||
|
||
--- | ||
|
||
Avantage : on peut se passer complétement avec ce plugin d'une installation locale d'un SGBD pour faire des développements. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.%' IDENTIFIED BY 'Zp3pbrya'; | ||
CREATE DATABASE creme; | ||
-- Connectez-vous à la base de données creme | ||
\c creme; | ||
|
||
-- Créez une table si elle n'existe pas déjà | ||
CREATE TABLE IF NOT EXISTS sauterelle ( | ||
id SERIAL PRIMARY KEY, | ||
nom VARCHAR(255) DEFAULT NULL, | ||
naissance DATE DEFAULT NULL, | ||
couleur VARCHAR(50) NOT NULL | ||
); | ||
|
||
-- Insérez des données dans la table | ||
INSERT INTO sauterelle (nom, naissance, couleur) VALUES ('Grillonne', '2024-03-29', 'Vert'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters