Skip to content

Commit 3f8b12b

Browse files
author
Evan Lin
authored
Merge pull request #221 from evanlinjin/master
Version 5.2
2 parents 92e5297 + 318789d commit 3f8b12b

File tree

7 files changed

+99
-34
lines changed

7 files changed

+99
-34
lines changed

Dockerfile

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,23 @@ COPY . /bbs
1313

1414
# `unsafe` flag used as work around to prevent infinite loop in Docker
1515
# see https://github.com/nodejs/node-gyp/issues/1236
16-
RUN npm install -g --unsafe @angular/cli && \
17-
cd /bbs/static && \
18-
yarn && \
19-
npm run build
16+
RUN cd /bbs/static && \
17+
rm -rf package-lock.json && \
18+
npm install -g --unsafe && \
19+
npm run build --prod
2020

2121
## Skycoin BBS Image
2222
FROM alpine:3.7
2323

24+
ENV DATA_DIR=/data \
25+
MESSENGER_ADDR=35.227.102.45:8005 \
26+
RPC_PORT=8996 \
27+
CXO_PORT=8998 \
28+
WEB_PORT=8080
29+
2430
RUN adduser -D skycoin
25-
RUN mkdir /data
26-
RUN chown skycoin: /data
31+
RUN mkdir $DATA_DIR
32+
RUN chown skycoin: $DATA_DIR
2733

2834
USER skycoin
2935

@@ -32,19 +38,18 @@ COPY --from=build-go /go/bin/* /usr/bin/
3238
COPY --from=build-node /bbs/static/dist /usr/local/bbs/static
3339
# volumes
3440

35-
VOLUME /data
41+
VOLUME $DATA_DIR
3642
WORKDIR /
3743

38-
EXPOSE 8080 8998
39-
40-
CMD [ \
41-
"bbsnode", \
42-
"--public=true", \
43-
"--memory=false", \
44-
"--config-dir=/data", \
45-
"--cxo-port=8998", \
46-
"--enforced-messenger-addresses=35.227.102.45:8005", \
47-
"--enforced-subscriptions=03588a2c8085e37ece47aec50e1e856e70f893f7f802cb4f92d52c81c4c3212742", \
48-
"--web-port=8080", \
49-
"--web-gui-dir=/usr/local/bbs/static" \
50-
]
44+
EXPOSE $RPC_PORT $CXO_PORT $WEB_PORT
45+
46+
CMD bbsnode \
47+
--public=true \
48+
--memory=false \
49+
--config-dir=$DATA_DIR \
50+
--rpc=true \
51+
--rpc-port=$RPC_PORT \
52+
--cxo-port=$CXO_PORT \
53+
--enforced-messenger-addresses=$MESSENGER_ADDR \
54+
--web-port=$WEB_PORT \
55+
--web-gui-dir=/usr/local/bbs/static

README.md

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Skycoin BBS uses the [Skycoin CX Object System](https://github.com/skycoin/cxo)
1111

1212
[![Skycoin BBS Showcase 4 - YouTube](https://i.ytimg.com/vi/6ZqwgefYauU/0.jpg)](https://youtu.be/6ZqwgefYauU)
1313

14-
## Installation
14+
## Install
1515

1616
### Go 1.9+ Installation and Setup
1717

@@ -46,7 +46,7 @@ but it must be cloned to this path: `$GOPATH/src/github.com/skycoin/bbs`.
4646

4747
Building instructions for static files can be found in [static/README.md](./static/README.md).
4848

49-
## Running BBS Node
49+
## Run
5050

5151
```bash
5252
$ bbsnode
@@ -62,14 +62,47 @@ The script [`run.sh`](./run.sh) is provided as a convenient to run BBS, serving
6262
$ ./run.sh
6363
```
6464

65-
## Using Skycoin BBS
65+
## Docker
6666

67-
There are currently two ways of interacting with Skycoin BBS.
68-
* **Web interface thin client -** By default, the flag `-web-gui` is enabled. Hence, when BBS is launched, the web gui will be served at a port specified by `-web-port`. One can only submit and view content via the thin client.
67+
Pull docker image.
6968

70-
* **Restful json api -** This is ideal for viewing/submitting content without a graphical user interface. Documentation for the api is provided as a [Postman](https://www.getpostman.com/) Collection located at [doc/bbs_postman_collection.json](doc/postman_collection.json) which can be viewed online at: [https://documenter.getpostman.com/view/985347/skycoin-bbs-v05/719YYTS](https://documenter.getpostman.com/view/985347/skycoin-bbs-v05/719YYTS). A brief written documentation is provided at [doc/api_explnation.md](./doc/api_explanantion.md).
69+
```bash
70+
$ docker pull skycoin/bbs
71+
```
72+
73+
Create a docker volume.
74+
75+
```bash
76+
$ docker volume create bbs-data
77+
```
78+
79+
Run Skycoin BBS.
80+
81+
```bash
82+
$ docker run -p 8080:8080 -p 8998:8998 -p 8996:8996 -v bbs0:/data skycoin/bbs
83+
```
84+
85+
List network interfaces.
86+
87+
```bash
88+
$ ifconfig
89+
```
90+
91+
Use CLI.
92+
93+
```bash
94+
# help menu
95+
$ docker run skycoin/bbs bbscli -h
96+
97+
# interact with bbs node
98+
$ docker run skycoin/bbs bbscli -a 172.17.0.1:8996 messengers discover
99+
```
100+
101+
## Command-line interface
102+
103+
The Command-line interface is for administration control over the BBS node.
71104

72-
* **Command-line interface -** This is for administration tools. Detailed instructions are located at [cmd/bbscli/README.md](./cmd/bbscli/README.md).
105+
Detailed instructions are located at [cmd/bbscli/README.md](./cmd/bbscli/README.md).
73106

74107
## Documentation
75108

cmd/bbscli/bbscli.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,20 @@ import (
1111
)
1212

1313
const (
14-
Version = "5.1"
14+
Version = "5.2"
1515
)
1616

1717
var (
1818
Port = 8996
19+
Address = ""
1920
)
2021

2122
func address() string {
22-
return "[::]:" + strconv.Itoa(Port)
23+
if Address != "" {
24+
return Address
25+
} else {
26+
return "[::]:" + strconv.Itoa(Port)
27+
}
2328
}
2429

2530
func call(method string, in interface{}) error {
@@ -46,6 +51,12 @@ func main() {
4651
Value: Port,
4752
Destination: &Port,
4853
},
54+
cli.StringFlag{
55+
Name: "address, a",
56+
Usage: "rpc address of the bbs node, over-rides 'port, p' flag",
57+
Value: Address,
58+
Destination: &Address,
59+
},
4960
}
5061
app.Commands = cli.Commands{
5162
{

cmd/bbsnode/bbsnode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
)
2121

2222
const (
23-
Version = "5.1"
23+
Version = "5.2"
2424

2525
defaultConfigSubDir = ".skybbs"
2626
defaultStaticSubDir = "static/dist"

pkg/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
VERSION=5.1
2+
VERSION=5.2
33
GOARCH=amd64
44
NAME=skycoin_bbs
55

src/store/cxo/manager.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"strings"
2424
"sync"
2525
"time"
26+
"github.com/skycoin/cxo/node/gnet"
2627
)
2728

2829
const (
@@ -178,14 +179,29 @@ func (m *Manager) prepareNode() error {
178179
for _, pk := range m.node.Feeds() {
179180
c.Subscribe(pk)
180181
}
182+
181183
m.file.SetConnectionStatus(c.Address(), true)
184+
m.l.Printf("Connected to '%s'", c.Address())
182185
}
183186

184187
c.OnCloseConnection = func(c *node.Conn) {
185188
m.file.SetConnectionStatus(c.Address(), false)
189+
m.l.Printf("Disconnected from '%s'", c.Address())
190+
186191
go func() {
187-
time.Sleep(time.Second * 2)
188-
m.node.Connect(c.Address())
192+
for {
193+
time.Sleep(time.Second * 2)
194+
switch c, e := m.node.Connect(c.Address()); e {
195+
case nil, gnet.ErrAlreadyListen:
196+
return
197+
default:
198+
if c == nil {
199+
m.l.Printf("Reconnecting due to error: '%s'", e.Error())
200+
} else {
201+
m.l.Printf("Reconnecting to `%s` due to error: '%s'", c.Address(), e.Error())
202+
}
203+
}
204+
}
189205
}()
190206
}
191207

static/dist/ngsw-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"/scripts.2ada44d001a2fa97ca64.bundle.js": "5101a13dcce062b23a11302fa35a1f696a16e3c4",
1515
"/styles.2d4560bcefdd3da68b61.bundle.css": "be6010d0d73dff3dc1b8372d5b423d8a3bc6343c",
1616
"/favicon.ico": "63f338aec4bb5adb37a6fb1b311c65835912c22f",
17-
"/assets/dust.png": "d0cd217d6531d84d578cd3a078957748359684fc",
1817
"/assets/logo.svg": "c84d898508bcca59b2113a54eb3ec4229acae416",
18+
"/assets/dust.png": "d0cd217d6531d84d578cd3a078957748359684fc",
1919
"/assets/nodes.svg": "15c1bf6a8e8668683fa85bd75057bfaecffd1939",
2020
"/index.html": "1312c017c1c98b525e394010cdefa42e3720ff71"
2121
},

0 commit comments

Comments
 (0)