1 Commits
17 changed files with 133 additions and 313 deletions
+4 -7
View File
@@ -1,16 +1,13 @@
# FROM basex/basexhttp:9.4.6
FROM basex/basexhttp:latest
# COPY ./bashrc /srv/.bashrc
# COPY ./inputrc /srv/.inputrc
COPY ./bashrc /srv/.bashrc
COPY ./inputrc /srv/.inputrc
# RUN basex "db:create('gdp','/srv/basex/src/gdp.tei.xml', (),map {'ftindex': true(),'stemming': true(),'casesens': true(),'diacritics': true(),'language': 'fr','updindex': true(),'autooptimize': true(),'maxlen': 96,'maxcats': 100,'splitsize': 0,'chop': false(),'textindex': true(),'attrindex': true(),'tokenindex': true(), 'xinclude': true()})"
COPY ./gdp-entrypoint.sh /usr/local/bin
USER root
RUN chmod +x /usr/local/bin/gdp-entrypoint.sh
# RUN chown -R basex:basex /usr/local/bin/gdp-entrypoint.sh
# # RUN ln -s /usr/local/bin/gdp-entrypoint.sh /srv/ # backwards compat
RUN chown -R basex:basex /srv
# USER basex
# RUN ln -s /usr/local/bin/gdp-entrypoint.sh /srv/ # backwards compat
USER basex
CMD ["/bin/sh","/usr/local/bin/gdp-entrypoint.sh"]
-32
View File
@@ -2,41 +2,9 @@
# todo: run some checks
id
ls -ls / | grep srv
echo "Creating GDP BaseX db"
basex "db:create('gdp','/srv/basex/src/gdp.tei.xml', (),map {'ftindex': true(),'stemming': true(),'casesens': true(),'diacritics': true(),'language': 'fr','updindex': true(),'autooptimize': true(),'maxlen': 96,'maxcats': 100,'splitsize': 0,'chop': false(),'textindex': true(),'attrindex': true(),'tokenindex': true(), 'xinclude': true()})"
# , 'serializer': 'indent=no'
echo "Creating FullText Index tmp file"
basex "xslt:transform(fn:doc('/srv/basex/src/gdp.tei.xml'), fn:doc('/srv/basex/src/xslt/generateFullTextIndex.xsl'))" > /tmp/gdpFtIndex.xml
echo "Creating FullText Index DB"
basex "db:create('gdpFtIndex', '/tmp/gdpFtIndex.xml', (),map {'ftindex': true(),'stemming': true(),'casesens': true(),'diacritics': true(),'language': 'fr','updindex': true(),'autooptimize': true(),'maxlen': 96,'maxcats': 100,'splitsize': 0,'chop': false(),'textindex': true(),'attrindex': true(),'tokenindex': true(), 'xinclude': true()})"
# , 'serializer': 'indent=no'
# echo "Creating Advanced Search Index"
# basex -q "import module namespace gdp.models.tei = 'gdp.models.tei' at '/srv/basex/webapp/synopsx/workspace/gdp/models/tei.xqm' ;
# let $index := ('gdpIndexNominum', 'gdpIndexLocorum')
# return gdp.models.tei:addId2IndexedEntities($index)"
# basex "declare namespace tei = 'http://www.tei-c.org/ns/1.0' ;
# let $db := db:open('gdp')
# let $index := $db//tei:TEI[tei:teiHeader//tei:sourceDesc[@xml:id = $indexId]]
# for $occurence in fn:distinct-values($index//tei:listRelation/tei:relation/@passive ! fn:tokenize(., '\s+'))
# let $entries := $index//*[tei:listRelation/tei:relation[fn:contains(@passive, $occurence)]]
# let $element := $db//*[@xml:id = fn:substring-after($occurence, '#')]
# let $values := for $entry in $entries/@xml:id return fn:concat('#', $entry)
# return
# if ($element[fn:not(@ref)])
# then insert node attribute ref { $values } into $element
# else replace value of node $element/@ref with $values"
# as we override the parent container CMD, we have to launch basexhttp here
echo "Launching basexhttp"
basexhttp
# todo never launched, prev command never ends
echo "Launching indexing"
wget -S http://localhost:8984/indexing
+9 -53
View File
@@ -1,68 +1,24 @@
# FROM node:lts-alpine
# RUN apk update && apk --no-cache add shadow && \
# usermod -u 1001 node && \
# groupmod -g 1001 node
# ARG UID=1000
# ARG UNAME=gdp
# ARG GID=1000
# ARG GNAME=users
# #RUN find / -group ${UID} -exec chgrp -h node {} \;
# #RUN find / -user ${UID} -exec chown -h node {} \;
# # RUN addgroup -g ${GID} ${GNAME}
# RUN if [ $(getent group ${GNAME}) ]; then echo "group ${GNAME} already exists"; else addgroup -g ${GID} ${GNAME}; fi
# # else
# # echo "group does not exist."
# # fi
# # adduser -h /home/gdp -D -u 1000 gdp && \
# RUN adduser -u ${UID} -G ${GNAME} -s /bin/sh -D ${UNAME}
# # chown -R gdp:gdp /home/gdp
# USER ${UNAME}
# COPY ./bashrc /home/${UNAME}/.bashrc
# COPY ./inputrc /home/${UNAME}/.inputrc
# COPY ./client-entrypoint.sh /usr/local/bin
# USER root
# RUN chmod +x /usr/local/bin/client-entrypoint.sh
# USER ${UNAME}
# CMD ["/bin/sh","/usr/local/bin/client-entrypoint.sh"]
# /////////////////////////////////////////////////////////////////////////////////
FROM node:16-alpine
FROM node:lts-alpine
RUN apk update && apk --no-cache add shadow && \
usermod -u 1001 node && \
groupmod -g 1001 node
# RUN find / -group 1000 -exec chgrp -h node {} \;
# RUN find / -user 1000 -exec chown -h node {} \;
RUN find / -group 1000 -exec chgrp -h node {} \;
RUN find / -user 1000 -exec chown -h node {} \;
ARG USER_UID
ARG USER_UNAME
ARG USER_GID
ARG USER_GNAME
RUN if [ $(getent group ${USER_GNAME}) ]; then echo "group ${USER_GNAME} already exists"; else addgroup -g ${USER_GID} ${USER_GNAME}; fi
# RUN addgroup -g 1000 ${USER_GNAME}
# RUN addgroup -g 1000 gdp && \
# adduser -h /home/gdp -D -u 1000 gdp && \
RUN adduser -u ${USER_UID} -G ${USER_GNAME} -s /bin/sh -D ${USER_UNAME}
RUN adduser -u 1000 -G users -s /bin/sh -D gdp
# chown -R gdp:gdp /home/gdp
USER ${USER_UNAME}
USER gdp
COPY ./bashrc /home/${USER_UNAME}/.bashrc
COPY ./inputrc /home/${USER_UNAME}/.inputrc
COPY ./bashrc /home/gdp/.bashrc
COPY ./inputrc /home/gdp/.inputrc
COPY ./client-entrypoint.sh /usr/local/bin
USER root
RUN chmod +x /usr/local/bin/client-entrypoint.sh
USER ${USER_UNAME}
USER gdp
CMD ["/bin/sh","/usr/local/bin/client-entrypoint.sh"]
+5 -23
View File
@@ -2,28 +2,10 @@
cat /etc/passwd|grep 1000
echo "Npm install"
cd /app
npm install
# echo "Cleaning node_modules"
# rm -rf node_modules
# echo "Cleaning npm cache"
# npm cache clean --f
# echo "Npm install"
# npm install
echo "Npm clean install"
npm ci
# echo "Run npm dev"
# npm run dev
echo "APP_ENV $APP_ENV"
if [ "$APP_ENV" = "prod" ]; then
echo "Run npm prod"
npm run prod
else
echo "Run npm dev"
npm run dev
fi
echo "Run npm dev"
npm run dev
+7
View File
@@ -0,0 +1,7 @@
FROM nginx:latest
COPY ./bashrc /root/.bashrc
COPY ./inputrc /root/.inputrc
COPY ./index.html /var/www/html/index.html
# COPY ./default.conf /etc/nginx/conf.d/default.conf
COPY ./default.conf /etc/nginx/nginx.conf
+3
View File
@@ -0,0 +1,3 @@
PS1='\e[36m\e[1mNGINX\e[0m:\e[90m\w\e[0m\n$ '
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
+49
View File
@@ -0,0 +1,49 @@
worker_processes 1;
events { worker_connections 1024; }
http {
upstream docker-api {
server basex:8984;
}
upstream docker-client {
server client:8988;
}
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
server {
listen 80;
root /var/www/html;
index index.html;
charset utf-8;
server_name dev.gdp.fr;
access_log on;
error_log /var/log/nginx/error.log error;
sendfile off;
client_max_body_size 100m;
location / {
try_files $uri $uri/ index.html;
}
location /api {
rewrite ^/api/(.*) /$1 break;
proxy_redirect off;
proxy_pass http://docker-api;
}
location /client {
rewrite ^/client/(.*) /$1 break;
proxy_redirect off;
proxy_pass http://docker-client;
}
}
}
+13
View File
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Proxy</title>
</head>
<body>
<ul>
<li><a href="/api">api</a></li>
<li><a href="/client">client</a></li>
</ul>
</body>
</html>
+2
View File
@@ -0,0 +1,2 @@
set show-all-if-ambiguous on
set completion-ignore-case on
-71
View File
@@ -1,71 +0,0 @@
#!/usr/bin/make
SHELL = /bin/sh
USER_UID := $(shell id -u)
USER_UNAME := $(shell id -un)
USER_GID := $(shell id -g)
USER_GNAME := $(shell id -gn)
export USER_UID
export USER_UNAME
export USER_GID
export USER_GNAME
build: build_basex build_client
build_basex:
docker-compose build basex
build_client:
docker-compose build --build-arg USER_UID=$(USER_UID) --build-arg USER_UNAME=$(USER_UNAME) --build-arg USER_GID=$(USER_GID) --build-arg USER_GNAME=$(USER_GNAME) client
buildnc: buildnc_basex buildnc_client
buildnc_basex:
docker-compose build --pull --no-cache basex
buildnc_client:
docker-compose build --no-cache --build-arg USER_UID=$(USER_UID) --build-arg USER_UNAME=$(USER_UNAME) --build-arg USER_GID=$(USER_GID) --build-arg USER_GNAME=$(USER_GNAME) client
up:
docker-compose up
upd:
docker-compose up -d
up_basex:
docker-compose up -d basex
up_client:
docker-compose up -d client
restart_basex:
docker-compose restart basex
restart_client:
docker-compose restart client
# upbuild:
# docker-compose up -d --build
ps:
docker-compose ps
logs:
docker-compose logs -f
logs_basex:
docker-compose logs basex -f
logs_client:
docker-compose logs client -f
down:
docker-compose down
exec_client:
docker exec -it gdp-client-1 sh
exec_basex:
docker exec -it gdp-basex-1 sh
exec_basex_root:
docker exec -u 0 -it gdp-basex-1 sh
+11 -110
View File
@@ -10,7 +10,7 @@ sudo pacman -S docker docker-compose docker-machine
this will clone this repos (main docker environement) and necessary other source code (synopsx, webapp, xml-tei sources, vuejs client)
```
git clone --recursive https://figureslibres.io/gogs/bachir/docker-gdp.git
git clone --recursive -o figli https://figureslibres.io/gogs/bachir/docker-gdp.git
```
## Docker
@@ -25,130 +25,31 @@ only before the first run (may take some time)
```
sudo docker-compose build
```
or with args for groups and users
```
docker-compose build --no-cache --build-arg UID=$(id -u) --build-arg GID=$(id -g) --build-arg UNAME=$(id -un) --build-arg GNAME=$(id -gn) [client | basex]
```
### run
then each time you want to launch the app
```
sudo docker-compose up -d
```
## API
the api is ready, you can go to http://localhost:8984/home
## DB
<del>connect http://localhost:8984/synopsx/create-project</del>
### indexing
before you can use the client you need to trigger this url http://localhost:8984/indexing
<del>create a 'gdp' project</del>
<del>connect to http://localhost:8984/synopsx/config</del>
<del>select 'gpd' and click on 'ok'</del>
## API
the api is ready, you can go to http://localhost:8984/gdp/home
## Client
open http://localhost:8998 in your browser
open http://localhost:8988 in your browser
## Vhost or Cross Origins Policy
Cross origin poilicy will block the api requests from client
You'll need to install vhost domain for api and client, like dev.gdp.net and dev.api.gdp.net
Or in firefox install this addon to allow cors addons.mozilla.org/en-US/firefox/addon/cors-everywhere/
## Logs
to follow the webpack compilation process, run
```
sudo docker-compose logs -f
```
## Update
update the code
```
git pull origin master
git pull --recurse-submodules
```
restart the containers
```
docker-compose restart basex
docker-compose restart client
```
or rebuild if data was updated
```
docker-compose up -d --build
```
or
```sh
docker-compose build --no-cache [client | basex]
docker-compose up -d [client | basex]
```
## Prod
run containers for prod
```
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
```
client will be built the client container stop
basex container will stay up
you have to serve client/dist/index.html with your own webserver (e.g. nginx, apache, etc)
### nginx conf
```nginx
server {
listen 80;
server_name dev.api.gdp.fr;
access_log off;
error_log /var/log/nginx/gdp/error.log error;
location / {
proxy_pass http://127.0.0.1:8984;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
add_header Access-Control-Allow-Origin *;
}
}
server {
listen 80;
server_name dev.gdp.fr;
access_log off;
error_log /var/log/nginx/gdp/error.log error;
location / {
proxy_pass http://127.0.0.1:8998;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
add_header Access-Control-Allow-Origin *;
}
}
```
## trouble shooting
/srv/basex has bad owner : 1000:users instead of basex:basex (1948:1984) (WHY ??)
```
docker exec -u 0 -it gdp-basex-1 sh
chown -R basex:basex /srv/basex
```
gdp-entrypoint is never launched, "launchit by hand" (WHY ??)
```
docker exec -it gdp-basex-1 sh
. /usr/local/bin/gdp-entrypoint.sh
```
## Doc
https://github.com/guidesDeParis/webapp/blob/master/install.md
+1 -1
Submodule client updated: 8494e5a0e2...01e4d99537
+1 -1
Submodule data updated: 1df122355a...423de0caf0
-7
View File
@@ -1,7 +0,0 @@
version: '3.7'
services:
basex:
restart: always
client:
environment:
- APP_ENV=prod
+26 -6
View File
@@ -7,26 +7,46 @@ services:
- "${WEBAPP_ROOT}:/srv/basex/webapp/synopsx/workspace/gdp"
- "${DATA_ROOT}:/srv/basex/src"
- basex-home:/srv
# - basex-data:/srv/basex/data
# - "${LOG_ROOT}:/var/log:rw"
ports:
- 1984:1984
- 8984:8984
working_dir: "/srv/basex"
networks:
- api
client:
build: ./Docker/client
volumes:
- "${CLIENT_ROOT}:/app"
- client-home:/home/${USER_UNAME}
# - client-home:/home/gdp
ports:
- 8998:8998
- 8988:8988
working_dir: "/app"
depends_on:
- basex
environment:
- APP_ENV=dev
networks:
- client
nginx:
build: ./Docker/nginx/
ports:
- 8999:80
volumes:
- "${LOG_ROOT}:/var/log:rw"
# working_dir: "/var/www/html"
depends_on:
- basex
- client
networks:
- api
- client
volumes:
basex-home:
client-home:
# client-home:
networks:
api:
client:
+1 -1
Submodule synopsx updated: a8b7c0c10a...558dd832a2
+1 -1
Submodule webapp updated: 2ca9ee51fd...e6ca72b4a0