Skip to content

Commit

Permalink
Scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
losfair committed Dec 16, 2021
1 parent 8a02c94 commit 52f3b9b
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 1 deletion.
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 1,14 @@
FROM ghcr.io/losfair/blueboat-mds:latest

FROM ghcr.io/losfair/blueboat:latest

WORKDIR /root
COPY --from=0 /usr/bin/blueboat-mds /usr/bin/
RUN apt update && apt install -y wget xxd
RUN wget -O /usr/bin/minio https://dl.min.io/server/minio/release/linux-amd64/minio && chmod x /usr/bin/minio \
&& wget https://s3.us-west-1.amazonaws.com/build-res.s3.univalent.net/foundationdb-clients_6.3.22-1_amd64.deb \
&& wget https://s3.us-west-1.amazonaws.com/build-res.s3.univalent.net/foundationdb-server_6.3.22-1_amd64.deb \
&& dpkg -i ./foundationdb-clients_6.3.22-1_amd64.deb ./foundationdb-server_6.3.22-1_amd64.deb \
&& rm ./foundationdb-clients_6.3.22-1_amd64.deb ./foundationdb-server_6.3.22-1_amd64.deb
COPY ./entrypoint.sh ./start_blueboat.sh ./mds.yaml ./fdbinit.sh /
ENTRYPOINT ["/entrypoint.sh"]
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 1,15 @@
# b6t
Minimal containerized Blueboat suitable for self-hosting.

Fully-featured, minimal containerized [Blueboat](https://github.com/losfair/blueboat) suitable for self-hosting.

## License

`b6t` itself is licensed under MIT, and all Blueboat *binaries* included in the b6t Docker image are available under the same license:

- `blueboat-server`
- `blueboat-mds`

The Docker image also contains various third-party software, which is licensed under the terms of the respective licenses:

- `minio` (AGPL-3.0)
- `foundationdb` (Apache-2.0)
42 changes: 42 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 1,42 @@
#!/bin/bash

set -e

mkdir -p /data/fdb

if [ ! -f "/mds_key.pub" ]; then
openssl genpkey -algorithm ed25519 -outform DER -out /mds_key.der
cat /mds_key.der | tail -c 17 | base64 > /mds_key.secret
openssl pkey -outform DER -pubout -inform DER -in /mds_key.der | tail -c 13 | xxd -p | tr -d '\n' > /mds_key.pub
echo "Generated MDS key at /mds_key.secret. Public key is $(cat /mds_key.pub)."
fi

if [ ! -f "/data/fdb.cluster" ]; then
echo "Setting up /data/fdb.cluster."
cp /etc/foundationdb/fdb.cluster /data/
fi

/usr/sbin/fdbserver --cluster_file /data/fdb.cluster \
--datadir /data/fdb \
--listen_address 127.0.0.1:4500 \
--logdir /var/log/foundationdb \
--public_address 127.0.0.1:4500 &

sleep 1
/fdbinit.sh

/usr/bin/blueboat-mds -l 0.0.0.0:2999 -c /mds.yaml &

/usr/bin/minio server --address 127.0.0.1:1932 /data/minio &

sleep 1

MDS_KEY="$(cat /mds_key.secret)" /start_blueboat.sh &

wait -n
last_status=$?

echo "A service has crashed. Shutting down."
kill $(jobs -p)
wait
exit $last_status
20 changes: 20 additions & 0 deletions fdbinit.sh
Original file line number Diff line number Diff line change
@@ -0,0 1,20 @@
#!/bin/bash

set -e

fdbcli --exec "configure new single ssd" || echo "Looks like FoundationDB is already configured."

bootstrap_script_tpl='
writemode on;
set "\x02m\x00\x02clusters\x00\x02local\x00" "{\"primary\":{\"region\":\"local\",\"config\":\"__FDB_CONFIG__\"},\"replicas\":[]}";
set "\x02m\x00\x02stores\x00\x02b\x00\x02info\x00" "{\"cluster\":\"local\",\"subspace\":\"b\"}";
set "\x02m\x00\x02stores\x00\x02b\x00\x02role-grants\x00" "{\"roles\":[\"service\"]}";
set "\x02m\x00\x02users\x00\x02__USER_PUBKEY__\x00\x02roles\x00" "{\"roles\":[\"service\"]}";
'

bootstrap_script=$(echo "$bootstrap_script_tpl" \
| sed s/__FDB_CONFIG__/"$(cat /data/fdb.cluster)"/g \
| sed s/__USER_PUBKEY__/"$(cat /mds_key.pub)"/g \
| tr -d '\n')

fdbcli --exec "$bootstrap_script"
4 changes: 4 additions & 0 deletions mds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 1,4 @@
rootStore:
primary: /etc/foundationdb/fdb.cluster
subspace: m
region: local
15 changes: 15 additions & 0 deletions start_blueboat.sh
Original file line number Diff line number Diff line change
@@ -0,0 1,15 @@
#!/bin/bash

set -e

if [ -z "$RUST_LOG" ]; then
export RUST_LOG=info
fi

export AWS_ACCESS_KEY_ID="minioadmin"
export AWS_SECRET_ACCESS_KEY="minioadmin"

exec /usr/bin/blueboat_server -l "0.0.0.0:3000" \
--s3-bucket "apps" --s3-region "us-east-1" \
--s3-endpoint "http://localhost:1932" \
--mds ws://localhost:2999/b --mds-local-region "local"

0 comments on commit 52f3b9b

Please sign in to comment.