Skip to content

Commit

Permalink
Merge pull request #20 from ahdinosaur/ssb-server
Browse files Browse the repository at this point in the history
update to latest ssb-server (again)
  • Loading branch information
ahdinosaur authored Mar 14, 2019
2 parents b4cc546 + fdc1589 commit f661242
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 19 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ ENV PATH=/home/node/.npm-global/bin:$PATH
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global

USER node
RUN npm install -g [email protected]
RUN npm install -g [email protected]

EXPOSE 8008

HEALTHCHECK --interval=30s --timeout=30s --start-period=10s --retries=10 \
CMD sbot whoami || exit 1
CMD ssb-server whoami || exit 1
ENV HEALING_ACTION RESTART

ENTRYPOINT [ "/tini", "--", "sbot" ]
CMD [ "server" ]
ENTRYPOINT [ "/tini", "--", "ssb-server" ]
CMD [ "start" ]
94 changes: 81 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ easily host your own [Secure ScuttleButt (SSB)](https://www.scuttlebutt.nz) pub

if you feel like sharing your pub, please add it to [the informal registry of pubs](https://github.com/ssbc/scuttlebot/wiki/Pub-Servers) as request-only or with a re-usable invite (`invite.create 1000`)!

(if you are running a v1 pub, [migrate to the latest v2!](#migrating-from-v1-to-v2) :tada: )

:heart:

## table of contents
Expand All @@ -19,7 +21,9 @@ if you feel like sharing your pub, please add it to [the informal registry of pu
- [command and control](#command-and-control)
- [create invites](#create-invites)
- [stop, start, restart containers](#stop-start-restart-containers)
- [upgrading](#upgrading)
- [update `ssb-pub` image](#update-ssb-pub-image)
- [migrating from v1 to v2](#migrating-from-v1-to-v2)

## one-click setup

Expand Down Expand Up @@ -70,18 +74,37 @@ ssh [email protected]
>
> point a domain name (example.com) to your pub server's IP address (using a DNS A record)
>
> edit `./create-sbot` to change `host` definition to say `host=example.com` where `example.com` is your domain name.
> edit `~/ssb-pub-data/config` to change the `connections.incoming.net[].external` property from your server ip address to your domain name:
>
> ```shell
> nano ./create-sbot
> ```json
> {
> "connections": {
> "incoming": {
> "net": [
> {
> "scope": "public",
> "host": "0.0.0.0",
> "external": ["hostname.yourdomain.tld"]
> "transform": "shs",
> "port": 8008
> }
> ]
> },
> "outgoing": {
> "net": [
> {
> "transform": "shs"
> }
> ]
> }
> }
> }
> ```
>
> then stop, remove, and re-create sbot:
> then restart sbot:
>
> ```shell
> docker stop sbot
> docker rm sbot
> ./create-sbot
> docker restart sbot
> ```
(credit to [seven1m/do-install-button](https://github.com/seven1m/do-install-button) for the Digital Ocean installer)
Expand Down Expand Up @@ -122,7 +145,7 @@ from GitHub:
```shell
git clone https://github.com/ahdinosaur/ssb-pub.git
cd ssb-pub
docker build -t ssb-pub .
docker build -t ahdinosaur/ssb-pub .
```

### create `sbot` container
Expand All @@ -140,20 +163,49 @@ chown -R 1000:1000 ~/ssb-pub-data
> rsync -avz ~/ssb-pub-data/blobs/sha256/ $HOST:~/ssb-pub-data/blobs/sha256/
> ```
#### step 2. run the container
#### step 2. setup ssb config
```shell
EXTERNAL=<hostname.yourdomain.tld>
cat > ~/ssb-pub-data/config <<EOF
{
"connections": {
"incoming": {
"net": [
{
"scope": "public",
"host": "0.0.0.0",
"external": ["${EXTERNAL}"],
"transform": "shs",
"port": 8008
}
]
},
"outgoing": {
"net": [
{
"transform": "shs"
}
]
}
}
}
EOF
```
#### step 3. run the container

create a `./create-sbot` script:

```shell
cat > ./create-sbot <<EOF
#!/bin/bash
ssb_host=<hostname.yourdomain.tld>
memory_limit=$(($(free -b --si | awk '/Mem\:/ { print $2 }') - 200*(10**6)))
memory_limit="\$((\$(free -b --si | awk '/Mem\:/ { print \$2 }') - 200*(10**6)))"
docker run -d --name sbot \
-v ~/ssb-pub-data/:/home/node/.ssb/ \
-e ssb_host="\$ssb_host" \
-p 8008:8008 \
--restart unless-stopped \
--memory "\$memory_limit" \
Expand All @@ -174,7 +226,7 @@ chmod +x ./create-sbot
./create-sbot
```

#### step 3. create `./sbot` script
#### step 4. create `./sbot` script

we will now create a shell script in `./sbot` to help us command our Scuttlebutt server running:

Expand Down Expand Up @@ -301,11 +353,27 @@ for `healer`
- `docker start healer`
- `docker restart healer`

## upgrading

### update `ssb-pub` image

```shell
docker pull ahdinosaur/ssb-pub
docker stop sbot
docker rm sbot
# edit ~/ssb-pub-data/config if necessary
./create-sbot
```

### migrating from `v1` to `v2`

for a `v1` pub owner to update to the latest `v2` version of `ssb-pub`:

1. pull the latest v2 image: `docker pull ahdinosaur/ssb-pub`
2. stop sbot container: `docker stop sbot`
3. remove sbot container: `docker rm sbot`
4. [create `~/ssb-pub-data/config`](#step-2-setup-ssb-config)
5. [re-create `./create-sbot`](#step-3-run-the-container)
6. `./create-sbot`

check things are working with `docker logs sbot` and `./sbot whoami` :tada:
31 changes: 29 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,35 @@ docker pull ahdinosaur/ssb-pub
mkdir ~/ssb-pub-data
chown -R 1000:1000 ~/ssb-pub-data

#
# setup sbot config
#
EXTERNAL=$(dig +short myip.opendns.com @resolver1.opendns.com)
cat > ~/ssb-pub-data/config <<EOF
{
"connections": {
"incoming": {
"net": [
{
"scope": "public",
"host": "0.0.0.0",
"external": ["${EXTERNAL}"],
"transform": "shs",
"port": 8008
}
]
},
"outgoing": {
"net": [
{
"transform": "shs"
}
]
}
}
}
EOF

#
# create sbot container
#
Expand All @@ -34,12 +63,10 @@ chown -R 1000:1000 ~/ssb-pub-data
cat > ./create-sbot <<EOF
#!/bin/bash
ssb_host=$(dig +short myip.opendns.com @resolver1.opendns.com)
memory_limit=$(($(free -b --si | awk '/Mem\:/ { print $2 }') - 200*(10**6)))
docker run -d --name sbot \
-v ~/ssb-pub-data/:/home/node/.ssb/ \
-e ssb_host="\$ssb_host" \
-p 8008:8008 \
--restart unless-stopped \
--memory "\$memory_limit" \
Expand Down

0 comments on commit f661242

Please sign in to comment.