fix quelque issue avec les script et le dependance entre les containers

This commit is contained in:
joseelinchevalay 2020-04-06 09:11:20 +02:00
parent 845b0b5332
commit de9d0e5a91
8 changed files with 87 additions and 35 deletions

View File

@ -44,18 +44,23 @@ services:
- mongo
depends_on:
- mongo
ssb-server:
build:
context: ./ssb-server
dockerfile: Dockerfile
volumes:
- ${SSB_PATH}:/home/astroport/.ssb
secret2dunikey:
build:
context: .
dockerfile: ./secret2dunikey/Dockerfile
volumes:
- ${SSB_PATH}:/home/astroport/.ssb
oasis:
build:
context: .
dockerfile: ./oasis/Dockerfile
tty: true
ports:
- 3000:3000
volumes:
- ${SSB_PATH}:/home/astroport/.ssb
depends_on:
- secret2dunikey
tip:
build:
context: .
@ -64,9 +69,9 @@ services:
volumes:
- ${SSB_PATH}:/home/astroport/.ssb
links:
- ssb-server
- oasis
depends_on:
- ssb-server
- oasis
- secret2dunikey
ipfs:
image: ipfs/go-ipfs

View File

@ -8,7 +8,8 @@ ENV NVM_DIR /usr/local/nvm
ENV NODE_VERSION v12.16.1
RUN apt-get update -y && \
apt-get install autoconf=2.69-11.1 build-essential=12.8 libsodium-dev=1.0.18-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 curl=7.68.0-1 -y && \
apt-get install autoconf=2.69-11.1 build-essential=12.8 python3-pip=20.0.2-2 python3-setuptools=44.0.0-1 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 curl=7.68.0-1 git=1:2.25.1-1 bc=1.07.1-2+b2 -y && \
pip3 install duniterpy==0.56.0 silkaj==0.7.6 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
useradd -ms /bin/bash astroport
@ -22,17 +23,15 @@ RUN git clone https://github.com/creationix/nvm.git $NVM_INSTALL_DIR && \
echo ". ${NVM_INSTALL_DIR}/nvm.sh" > /home/astroport/.bashrc && \
chown -R astroport:astroport $NVM_DIR
USER astroport
WORKDIR /home/astroport
USER astroport
RUN . ~/.bashrc && \
mkdir -p /home/astroport/.ssb/ && \
npm install -g sodium-native@3.0.0 ssb-backlinks@1.0.0 && \
npm install -g ssb-server@15.2.0
COPY ./run-ssb-pub.sh /home/astroport/run-ssb-pub.sh
npm install -g fraction/oasis#semver:
VOLUME [ "/home/astroport/.ssb"]
EXPOSE 3000
EXPOSE 8008
VOLUME [ "/home/astroport/.ssb" ]
ENTRYPOINT [ "/bin/bash" ]
CMD [ "/home/astroport/run-ssb-pub.sh" ]
ENTRYPOINT ["/bin/bash"]
CMD ["-c", ". ~/.bashrc && oasis --host 0.0.0.0 --open false && tail -f /dev/null"]

View File

@ -101,14 +101,11 @@ The main clients for Duniter are [Cesium](https://cesium.app/) and [Silkaj](http
### variables
SSB_PATH : this is important variable to locate your ssb db path and secret file don't forget to set that.
if you use patchwork or other project please *copy all directory other location* because a
lock file is create when a patchwork or other projet run and ssb-server cannot run.
First you need to build docker image.
```
SSB_PATH=~/your-copy-ssb/ docker-compose build
SSB_PATH=~/.ssb/ docker-compose build
```
create your dunikey
@ -127,7 +124,7 @@ container_id=$(docker ps -a -q --filter="ancestor=ssb-g1like_tip") && docker exe
For display thank you file
```
container_id=$(docker ps -a -q --filter="ancestor=ssb-g1like_tip") && docker cp $container_id:/home/astroport/your_thank.md ~ && docker exec -ti $container_id bash -c "rm -rf /home/astroport/your_thank.md"
container_id=$(docker ps -a -q --filter="ancestor=ssb-g1like_tip") && docker cp $container_id:/home/astroport/thank-your-butts-$(date -u +%Y-week-%W).md ~ && docker exec -ti $container_id bash -c "rm -rf /home/astroport/thank-your-butts-$(date -u +%Y-week-%W).md"
```
## Authors

View File

@ -1,6 +0,0 @@
#!/bin/bash
. ~/.bashrc
while true; do
ssb-server start
done

View File

@ -28,14 +28,15 @@ RUN git clone https://github.com/creationix/nvm.git $NVM_INSTALL_DIR && \
COPY ./samples /home/astroport/samples
COPY ./tip/tip.sh /home/astroport/tip
RUN chmod +x /home/astroport/samples /home/astroport/tip
COPY ./tip/sbotc.js /home/astroport/sbotc.js
RUN chmod +x /home/astroport/samples /home/astroport/tip /home/astroport/sbotc.js
USER astroport
WORKDIR /home/astroport/
RUN . ~/.bashrc && \
mkdir -p /home/astroport/.ssb/ && \
npm install -g sodium-native@3.0.0 ssb-backlinks@1.0.0 && \
npm install -g ssb-server@15.2.0
WORKDIR /home/astroport
npm install commander@5.0.0 ssb-client@4.9.0 pull-stream@3.6.14
VOLUME [ "/home/astroport/.ssb"]
ENTRYPOINT ["/bin/bash"]
CMD ["-c", "tail" ,"-f", "/dev/null"]

56
tip/sbotc.js Executable file
View File

@ -0,0 +1,56 @@
const {program} = require("commander");
const ssbClient = require('ssb-client');
const pull = require('pull-stream');
let convertToInt = (value) => {
return parseInt(value);
}
let throwProgram = (err) => {
console.error(err.message);
process.exit(1);
}
program.version('.0.0.1');
program
.requiredOption('-s, --host <value>', 'host name or ip of ssb-server', 'oasis')
.requiredOption('-p, --port <number>', 'port of ssb-server', convertToInt, 8008)
/**
* whoami command
*/
program
.command('whoami')
.description('return your identity')
.action(() => {
ssbClient({host:program.host, port:program.port}, (err, sbot) => {
if(err) throwProgram(err)
sbot.whoami((err, identity) =>{
if(err) throwProgram
console.log(JSON.stringify(identity));
sbot.close();
})
})
});
/**
* query
*/
program
.command('query <query>')
.description('you can execute a query')
.action((query) => {
ssbClient({host:program.host, port:program.port}, (err, sbot) =>{
if(err) throwProgram(err);
pull(sbot.query.read({query:JSON.parse(query)}),pull.collect( (err, array) => {
if(err) throwProgram(err);
array.forEach((result) => {
console.log(JSON.stringify(result));
})
sbot.close();
}))
})
});
program.parse(process.argv);

View File

@ -1,4 +1,4 @@
#!/bin/bash
. ~/.bashrc
ssb-server --host ssb-server --port 8008 $@
node ~/sbotc.js $@

View File

@ -174,7 +174,7 @@ process_msg() {
msg=$1
target_id=$(printf %s "$msg" | jq -r '.value?.content?.vote?.link') || return 1
target_msg=$(sbotc query.read '[{"$filter":{"value":{"content":{}},"key":"'"$target_id"'"}}]') || return 1
target_msg=$(sbotc query '[{"$filter":{"value":{"content":{}},"key":"'"$target_id"'"}}]') || return 1
target_author=$(printf %s "$target_msg" | jq -r .author) || return 1
msg_content=$(printf %s "$target_msg" | jq -r .content?.text) || return 1
@ -191,7 +191,7 @@ process_author() {
author_id=$1
g1_author=$(echo $author_id | cut -d '.' -f 1 | cut -d '@' -f2 | base64 -d | base58)
author_name=$(sbotc query.read '[{"$filter":{"value":{"content":{"about":"'"$author_id"'"}}}}]' | jq .value?.content?.name | grep -v null | tail -n 1)
author_name=$(sbotc query '[{"$filter":{"value":{"content":{"about":"'"$author_id"'"}}}}]' | jq .value?.content?.name | grep -v null | tail -n 1)
author_name=${author_name:1:-1}
}
@ -199,7 +199,7 @@ authorsNb=0
i=0
messages=$(sbotc query.read '[{"$filter":{"value":{"author":"'"$self"'","content":{"type":"vote","vote":{"expression":"Like"}},"timestamp":{"$gt":'"$last_ts"'}}}}]')
messages=$(sbotc query '[{"$filter":{"value":{"author":"'"$self"'","content":{"type":"vote","vote":{"expression":"Like"}},"timestamp":{"$gt":'"$last_ts"'}}}}]')
while read -r msg
do
priv=$(printf %s "$msg" | jq .value.content.private)