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

support Docker #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM node:10.17.0-jessie

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y libodbc1 && npm install -g pm2 \
&& mkdir /data && cd /data \
&& wget -q --no-check-certificate https://repo.mongodb.org/apt/debian/dists/jessie/mongodb-org/3.2/main/binary-amd64/mongodb-org-server_3.2.10_amd64.deb \
&& wget -q --no-check-certificate https://sphinxsearch.com/files/sphinxsearch_2.3.2-beta-1~jessie_amd64.deb \
&& dpkg -i *.deb && rm -f *.deb \
&& sed -i 's/127.0.0.1/0.0.0.0/' /etc/mongod.conf

ADD . /ssbc
WORKDIR /ssbc

RUN chmod a+x /ssbc/entrypoint.sh \
&& cd spider && npm install && cd .. \
&& cd web && npm install && npm run build && cd .. \
&& mkdir -p /data/bt/index/db /data/bt/index/binlog


VOLUME ["/var/lib/mongodb"]
EXPOSE 27017 3001 6881/udp

ENTRYPOINT ["/ssbc/entrypoint.sh"]

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ mkdir -p /data/bt/index/db /data/bt/index/binlog

3. 初始化索引

``
```
cd spider
indexer -c sphinx.conf hash
searchd -c sphinx.conf
``
```


## 网站说明
Expand Down
26 changes: 26 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

/usr/bin/mongod --quiet --config /etc/mongod.conf --fork

sleep 6

cd /ssbc/spider && pm2 start ecosystem.config.js && cd ..

cd web && pm2 start ecosystem.config.js && cd ..

trap 'kill $(pgrep searchd) 2>/dev/null; pm2 kill; kill $(pgrep mongod); exit 0' SIGINT SIGTERM

sleep 3 &
wait

cd spider
if [ ! -e /data/.inited ]; then
indexer -c sphinx.conf hash &
wait
echo 1 >/data/.inited
fi
searchd -c sphinx.conf && cd ..

sleep infinity &
wait

2 changes: 1 addition & 1 deletion spider/dump.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const MongoClient = require('mongodb').MongoClient
const crc32 = require('buffer-crc32')

MongoClient.connect('mongodb://localhost:27017/admin', {useNewUrlParser: true}, (err, mconn) => {
MongoClient.connect('mongodb://localhost:27017/admin', {useNewUrlParser: true, useUnifiedTopology: true}, (err, mconn) => {
if(err) {
console.error(err)
process.exit(1)
Expand Down
1 change: 1 addition & 0 deletions web/ecosystem.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
script : "./server",
env: {
NODE_ENV: 'production',
HOST: '0.0.0.0',
PORT: 3001,
BASE_URL: 'http://127.0.0.1:3000'
}
Expand Down