Retrait de CouchDB
This commit is contained in:
36
compose.yaml
36
compose.yaml
@@ -99,42 +99,6 @@ services:
|
|||||||
caddy.reverse_proxy: "{{upstreams 80}}"
|
caddy.reverse_proxy: "{{upstreams 80}}"
|
||||||
caddy.tls: internal
|
caddy.tls: internal
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
|
||||||
# Documents
|
|
||||||
#
|
|
||||||
# ----------------------------------------------------------------------
|
|
||||||
# CouchDB
|
|
||||||
# Single-node document database
|
|
||||||
# https://couchdb.apache.org/
|
|
||||||
couchdb:
|
|
||||||
image: couchdb:3.5
|
|
||||||
volumes:
|
|
||||||
- couchdb_data:/opt/couchdb/data
|
|
||||||
environment:
|
|
||||||
COUCHDB_USER: ${COUCHDB_USER}
|
|
||||||
COUCHDB_PASSWORD: ${COUCHDB_PASSWORD}
|
|
||||||
ports:
|
|
||||||
- 5984:5984
|
|
||||||
networks:
|
|
||||||
- caddy_net
|
|
||||||
labels:
|
|
||||||
caddy: couchdb.localhost
|
|
||||||
caddy.reverse_proxy: "{{upstreams 5984}}"
|
|
||||||
caddy.tls: internal
|
|
||||||
|
|
||||||
couchdb-init:
|
|
||||||
build:
|
|
||||||
dockerfile: ./couchdb-init.Dockerfile
|
|
||||||
context: .
|
|
||||||
environment:
|
|
||||||
COUCHDB_USER: ${COUCHDB_USER}
|
|
||||||
COUCHDB_PASSWORD: ${COUCHDB_PASSWORD}
|
|
||||||
depends_on:
|
|
||||||
- couchdb
|
|
||||||
networks:
|
|
||||||
- caddy_net
|
|
||||||
|
|
||||||
|
|
||||||
# Redis
|
# Redis
|
||||||
# In-memory key-value database
|
# In-memory key-value database
|
||||||
# https://redis.io/fr/
|
# https://redis.io/fr/
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
FROM python:3.13-slim
|
|
||||||
|
|
||||||
# Installer requests une seule fois dans l'image
|
|
||||||
RUN python3 -m pip install --no-cache-dir requests
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copier le script Python
|
|
||||||
COPY couchdb-init.py /app/
|
|
||||||
|
|
||||||
# Lancer le script par défaut
|
|
||||||
ENTRYPOINT ["python3", "couchdb-init.py"]
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
import os, time, requests
|
|
||||||
|
|
||||||
COUCHDB_URL = 'http://couchdb:5984'
|
|
||||||
USER = os.getenv('COUCHDB_USER', 'admin')
|
|
||||||
PASSWORD = os.getenv('COUCHDB_PASSWORD', 'password')
|
|
||||||
|
|
||||||
for _ in range(30):
|
|
||||||
try:
|
|
||||||
r = requests.get(COUCHDB_URL)
|
|
||||||
if r.ok:
|
|
||||||
break
|
|
||||||
except Exception:
|
|
||||||
time.sleep(2)
|
|
||||||
else:
|
|
||||||
print('❌ CouchDB n\'est pas joignable')
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
print('🚀 Vérification de la configuration...')
|
|
||||||
try:
|
|
||||||
dbs = requests.get(f'{COUCHDB_URL}/_all_dbs', auth=(USER, PASSWORD))
|
|
||||||
if dbs.ok and '_users' in dbs.json():
|
|
||||||
print('✅ CouchDB déjà initialisé.')
|
|
||||||
exit(0)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
print('🛠 Initialisation du mode single-node...')
|
|
||||||
payload = {
|
|
||||||
"action": "enable_single_node",
|
|
||||||
"username": USER,
|
|
||||||
"password": PASSWORD,
|
|
||||||
"bind_address": "0.0.0.0"
|
|
||||||
}
|
|
||||||
r1 = requests.post(f'{COUCHDB_URL}/_cluster_setup', auth=(USER, PASSWORD), json=payload)
|
|
||||||
|
|
||||||
if r1.ok:
|
|
||||||
print('✅ CouchDB initialisé avec succès.')
|
|
||||||
else:
|
|
||||||
print('❌ Erreur lors de l\'initialisation :', r1.text)
|
|
||||||
63
couchdb.http
63
couchdb.http
@@ -1,63 +0,0 @@
|
|||||||
@couchDB = http://couchdb.localhost
|
|
||||||
|
|
||||||
### Init
|
|
||||||
|
|
||||||
POST {{couchDB}}/_cluster_setup
|
|
||||||
Authorization: Basic {{$dotenv COUCHDB_USER}}:{{$dotenv COUCHDB_PASSWORD}}
|
|
||||||
Content-Type: application/json
|
|
||||||
|
|
||||||
{
|
|
||||||
"action": "enable_single_node",
|
|
||||||
"username": "{{$dotenv COUCHDB_USER}}",
|
|
||||||
"password": "{{$dotenv COUCHDB_PASSWORD}}",
|
|
||||||
"bind_address": "0.0.0.0",
|
|
||||||
"port": 5984
|
|
||||||
}
|
|
||||||
|
|
||||||
###
|
|
||||||
|
|
||||||
GET {{couchDB}}/_all_dbs
|
|
||||||
Authorization: Basic {{$dotenv COUCHDB_USER}}:{{$dotenv COUCHDB_PASSWORD}}
|
|
||||||
|
|
||||||
### Creates a new database.
|
|
||||||
PUT {{couchDB}}/db
|
|
||||||
Authorization: Basic {{$dotenv COUCHDB_USER}}:{{$dotenv COUCHDB_PASSWORD}}
|
|
||||||
|
|
||||||
### Creates a new document in the specified database, using the supplied JSON document structure.
|
|
||||||
POST {{couchDB}}/db
|
|
||||||
Accept: application/json
|
|
||||||
Content-Type: application/json
|
|
||||||
Authorization: Basic {{$dotenv COUCHDB_USER}}:{{$dotenv COUCHDB_PASSWORD}}
|
|
||||||
|
|
||||||
{
|
|
||||||
"servings": 4,
|
|
||||||
"subtitle": "Delicious with fresh bread",
|
|
||||||
"title": "Fish Stew"
|
|
||||||
}
|
|
||||||
|
|
||||||
###
|
|
||||||
GET {{couchDB}}/db/_all_docs
|
|
||||||
Authorization: Basic {{$dotenv COUCHDB_USER}}:{{$dotenv COUCHDB_PASSWORD}}
|
|
||||||
|
|
||||||
###
|
|
||||||
GET {{couchDB}}/db/2c2135ff744c3b98407572ed4f000cad
|
|
||||||
Authorization: Basic {{$dotenv COUCHDB_USER}}:{{$dotenv COUCHDB_PASSWORD}}
|
|
||||||
|
|
||||||
###
|
|
||||||
POST {{couchDB}}/db/_find
|
|
||||||
Authorization: Basic {{$dotenv COUCHDB_USER}}:{{$dotenv COUCHDB_PASSWORD}}
|
|
||||||
Accept: application/json
|
|
||||||
Content-Type: application/json
|
|
||||||
Content-Length: 168
|
|
||||||
Host: localhost:5984
|
|
||||||
|
|
||||||
{
|
|
||||||
"selector": {
|
|
||||||
"year": {"$gt": 2010}
|
|
||||||
},
|
|
||||||
"fields": ["_id", "_rev", "year", "title"],
|
|
||||||
"sort": [{"year": "asc"}],
|
|
||||||
"limit": 2,
|
|
||||||
"skip": 0,
|
|
||||||
"execution_stats": true
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
-4.006666897046123 48.7528720020309,
|
|
||||||
-4.005870355067274 48.75026102618178,
|
|
||||||
-4.003629135498721 48.748652881336724,
|
|
||||||
-3.999937714914126 48.7464361648583,
|
|
||||||
-3.9950927255526962 48.74493656593118,
|
|
||||||
-3.9940050748797225 48.745523370840516,
|
|
||||||
-3.9910057957512173 48.745762437542936,
|
|
||||||
-3.9901158997460566 48.74515390188169,
|
|
||||||
-3.991851437957331 48.74306933218229,
|
|
||||||
-3.9887834656682424 48.7393151550319,
|
|
||||||
-3.993896752679784 48.73699956468981,
|
|
||||||
-3.9941353727403235 48.74093375678278,
|
|
||||||
-3.9980896480292487 48.74147327911715,
|
|
||||||
-4.000544025794788 48.740416709111294,
|
|
||||||
-4.00364608658179 48.741630638707136,
|
|
||||||
-4.005077806945022 48.740394228657095,
|
|
||||||
-4.007054944589484 48.740956236995665,
|
|
||||||
-4.008248044892178 48.74050663082754,
|
|
||||||
-4.008657107853101 48.740888796326814,
|
|
||||||
-4.007157210329716 48.74122599876611,
|
|
||||||
-4.00933887945464 48.7431367698581,
|
|
||||||
-4.009234652034756 48.74313664396521,
|
|
||||||
-4.006666897046123 48.7528720020309,
|
|
||||||
|
|
||||||
54,41,42,1,1,"LINESTRING (-4.0283457106078151 48.74819693416071686, -4.0277798896546626 48.74843925273770395, -4.02709096211884532 48.74871478406565473, -4.02662791246362506 48.74891584651362564, -4.02625521396064201 48.74902010079956938, -4.02561146200094466 48.7490424409755434, -4.02451595428005682 48.74905733442068367, -4.02391737789647941 48.74907222786141858, -4.02363503054573446 48.7490349942513248, -4.02274281291738145 48.74909456801422181, -4.02174895024276235 48.74906478114159114, -4.02093578987261857 48.74906478114159114, -4.02015407493021737 48.74906065795587295)"
|
|
||||||
56,42,37,1,1,"LINESTRING (-4.02015407493021737 48.74906065795587295, -4.01973160932402873 48.74875605686673197, -4.01938565220795851 48.74824615905019698, -4.01924319927781237 48.74797778970009432, -4.01875478923159868 48.74780334885392818, -4.0183884816969373 48.74761548880393036, -4.01783902039494478 48.74741420939959369, -4.01763551620902248 48.74705190444013425, -4.01739131118591519 48.74666275916671054, -4.01718780699999201 48.7464614759462691, -4.01674202846954209 48.74639773953580146)"
|
|
||||||
96,65,62,1,1,"LINESTRING (-4.02286843896043855 48.74610257019232051, -4.02284812996929819 48.74649092768017766, -4.02273179974516371 48.7467133780762012, -4.02244097418483104 48.74677474352942141, -4.02211524955725697 48.74681309689962205, -4.02174299284003034 48.74674406081217626, -4.02134747007797611 48.74662900045570524, -4.02106827754005636 48.74655229340503126, -4.02083561709178827 48.74679775555504335, -4.02053315850904092 48.74708156967139416, -4.02028886503836169 48.74713526405361819, -4.0200562045900945 48.74690514486865567, -4.01975199012698514 48.74659331482603619)"
|
|
||||||
85,35,60,1,1,"LINESTRING (-4.01847183812000619 48.74490975460546593, -4.01851483744327798 48.7451174969493124, -4.01875102113744109 48.74550314198440759, -4.01912216694255253 48.74588878406018466, -4.01942583169218981 48.74622992650653686, -4.01975199012698514 48.74659331482603619)"
|
|
||||||
|
@@ -1,59 +0,0 @@
|
|||||||
set SEARCH_PATH to public,postgis;
|
|
||||||
|
|
||||||
create table point (
|
|
||||||
id serial primary key,
|
|
||||||
nom text not null,
|
|
||||||
altitude double precision,
|
|
||||||
geom geometry(point, 4326) not null
|
|
||||||
);
|
|
||||||
|
|
||||||
create index idx_point_geom
|
|
||||||
on point using gist (geom);
|
|
||||||
|
|
||||||
create table route (
|
|
||||||
id serial primary key,
|
|
||||||
depart int,
|
|
||||||
arrivee int,
|
|
||||||
geom geometry(linestring, 4326) not null,
|
|
||||||
longueur double precision
|
|
||||||
);
|
|
||||||
|
|
||||||
create index idx_route_geom
|
|
||||||
on route using gist (geom);
|
|
||||||
|
|
||||||
create or replace function maj_longueur()
|
|
||||||
returns trigger as $$
|
|
||||||
begin
|
|
||||||
new.longueur := st_length(new.geom) * 1000;
|
|
||||||
return new;
|
|
||||||
end;
|
|
||||||
$$ language plpgsql;
|
|
||||||
|
|
||||||
create trigger trigger_longueur
|
|
||||||
before insert or update on route
|
|
||||||
for each row
|
|
||||||
execute function maj_longueur();
|
|
||||||
|
|
||||||
-- ************************************************************
|
|
||||||
|
|
||||||
create table route_cout (
|
|
||||||
route_id int references route(id),
|
|
||||||
tag text,
|
|
||||||
cout float,
|
|
||||||
cout_inverse float,
|
|
||||||
primary key (route_id, tag)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table zone (
|
|
||||||
id int primary key,
|
|
||||||
nom text,
|
|
||||||
categorie text,
|
|
||||||
geom geometry(polygon, 4326) -- on choisit srid 4326 (wgs84)
|
|
||||||
);
|
|
||||||
|
|
||||||
-- ************************************************************
|
|
||||||
|
|
||||||
\COPY point FROM '/tmp/point.csv' (FORMAT CSV, header, ENCODING 'UTF8');
|
|
||||||
\COPY route(id, depart, arrivee, geom) FROM '/tmp/route.csv' (FORMAT CSV, header, ENCODING 'UTF8');
|
|
||||||
\COPY route_cout FROM '/tmp/route_cout.csv' (FORMAT CSV, header, ENCODING 'UTF8');
|
|
||||||
\COPY zone FROM '/tmp/zone.csv' (FORMAT CSV, header, ENCODING 'UTF8');
|
|
||||||
@@ -4,8 +4,8 @@ SELECT plan(4);
|
|||||||
|
|
||||||
SELECT is(
|
SELECT is(
|
||||||
(SELECT nb_total_familles FROM nb_total_familles),
|
(SELECT nb_total_familles FROM nb_total_familles),
|
||||||
137::bigint,
|
138::bigint,
|
||||||
'La table famille contient 137 enregistrements'
|
'La table famille contient 138 enregistrements'
|
||||||
);
|
);
|
||||||
|
|
||||||
SELECT is(
|
SELECT is(
|
||||||
|
|||||||
Reference in New Issue
Block a user