Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(#9542): Research CouchDB Nouveau #9541

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions couchdb-nouveau/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM couchdb:3.4.1-nouveau AS base

# temporary fix https://github.com/apache/couchdb/issues/5262
RUN apt-get update && apt-get install -y wget unzip
RUN wget https://github.com/user-attachments/files/17186496/nouveau-1.0-SNAPSHOT-4299acf4.jar.zip -O /tmp/nouveau-4299acf4.jar.zip
RUN unzip /tmp/nouveau-4299acf4.jar.zip -d /tmp

FROM couchdb:3.4.1-nouveau

COPY --chown=nouveau:nouveau --from=base /tmp/nouveau-1.0-SNAPSHOT-4299acf4.jar /opt/nouveau/lib/nouveau-1.0-SNAPSHOT.jar
COPY --chown=nouveau:nouveau nouveau.yaml /opt/nouveau/etc/nouveau.yaml

VOLUME /data/nouveau

# 5987: Nouveau App
# 5989: Nouveau Admin
EXPOSE 5987 5989

LABEL Authors="MEDIC SRE TEAM<[email protected]>"
27 changes: 27 additions & 0 deletions couchdb-nouveau/nouveau.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
maxIndexesOpen: 3000
commitIntervalSeconds: 30
idleSeconds: 60
rootDir: ./data/nouveau

logging:
level: INFO

server:
applicationConnectors:
- type: http
bindHost: 0.0.0.0
port: 5987
useDateHeader: false
adminConnectors:
- type: http
bindHost: 0.0.0.0
port: 5989
useDateHeader: false
gzip:
includedMethods:
- GET
- POST
requestLog:
appenders:
- type: console
target: stderr
4 changes: 4 additions & 0 deletions couchdb/10-docker-default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ n=1
[attachments]
compressible_types = text/*, application/javascript, application/json, application/xml
compression_level = 8

[nouveau]
enable = true
url = http://nouveau:5987
2 changes: 1 addition & 1 deletion couchdb/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM couchdb:3.3.3 as base_couchdb_build
FROM couchdb:3.4.1 AS base_couchdb_build

COPY --chown=couchdb:couchdb 10-docker-default.ini /opt/couchdb/etc/default.d/
COPY --chown=couchdb:couchdb vm.args /opt/couchdb/etc/
Expand Down
1 change: 1 addition & 0 deletions ddocs/medic-db/medic-nouveau/_id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_design/medic-nouveau
47 changes: 47 additions & 0 deletions ddocs/medic-db/medic-nouveau/nouveau/contacts_by_freetext/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
function(doc) {
const skip = [ '_id', '_rev', 'type', 'refid', 'geolocation' ];
let toIndex = '';

const types = [ 'district_hospital', 'health_center', 'clinic', 'person' ];
let idx;
if (doc.type === 'contact') {
idx = types.indexOf(doc.contact_type);
if (idx === -1) {
idx = doc.contact_type;
}
} else {
idx = types.indexOf(doc.type);
}

const isContactDoc = idx !== -1;
if (isContactDoc) {
Object.keys(doc).forEach(function(key) {
const value = doc[key];
if (!key || !value) {
return;
}

key = key.toLowerCase();
if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {
return;
}

if (typeof value === 'string') {
toIndex += ' ' + value;
}

/*if (typeof value === 'number') {
index('double', key, value, { store: true });
}*/

/*if (typeof value === 'string') {
index('text', key, value, { store: true });
}*/
});

toIndex = toIndex.trim();
if (toIndex) {
index('text', 'default', toIndex, { store: true });
}
}
}
2 changes: 1 addition & 1 deletion nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# base build
FROM nginx:1.25.1-alpine as base_nginx
FROM nginx:1.25.1-alpine AS base_nginx
RUN apk add --update --no-cache \
curl \
socat \
Expand Down
15 changes: 15 additions & 0 deletions scripts/build/cht-couchdb-single-node.yml.template
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ services:
networks:
cht-net:

nouveau:
image: {{{ repo }}}/cht-couchdb-nouveau:{{ tag }}
volumes:
- ${COUCHDB_NOUVEAU_DATA:-./srv_nouveau}:/data/nouveau
restart: always
depends_on:
- couchdb
logging:
driver: "local"
options:
max-size: "${LOG_MAX_SIZE:-50m}"
max-file: "${LOG_MAX_FILES:-20}"
networks:
cht-net:

volumes:
cht-credentials:

Expand Down
2 changes: 1 addition & 1 deletion scripts/build/versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ module.exports = {
getRepo,
escapeBranchName,
SERVICES: ['api', 'sentinel'],
INFRASTRUCTURE: ['couchdb', 'haproxy', 'haproxy-healthcheck', 'nginx'],
INFRASTRUCTURE: ['couchdb', 'couchdb-nouveau', 'haproxy', 'haproxy-healthcheck', 'nginx'],
};
Loading