Add support for running oasis in a docker container

This commit is contained in:
Stephen Solka 2020-01-01 10:07:41 -05:00
parent 67fcb7b19b
commit 4882934610
5 changed files with 33 additions and 7 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
node_modules

18
Dockerfile Normal file
View File

@ -0,0 +1,18 @@
FROM node:12-alpine
RUN apk add --update --no-cache libtool autoconf automake alpine-sdk python3
RUN mkdir /app
WORKDIR /app
ADD package.json .
ADD yarn.lock .
RUN yarn
ADD . ./
EXPOSE 3000
EXPOSE 8008
VOLUME /root/.ssb
ADD https://github.com/just-containers/s6-overlay/releases/download/v1.21.8.0/s6-overlay-amd64.tar.gz /tmp/
RUN tar xzf /tmp/s6-overlay-amd64.tar.gz -C /
RUN mkdir /etc/services.d/sbot/
RUN printf "#!/usr/bin/execlineb -P\n/usr/local/bin/node /app/server.js" >> /etc/services.d/sbot/run
RUN mkdir /etc/services.d/oasis/
RUN printf "#!/usr/bin/execlineb -P\n/usr/local/bin/node /app/index.js --host 0.0.0.0 --open false" >> /etc/services.d/oasis/run
ENTRYPOINT ["/init"]

View File

@ -34,6 +34,14 @@ With [yarn](https://yarnpkg.com/en/):
yarn global add @fraction/oasis@latest
```
With [docker](https://www.docker.com/)
```shell
docker build . -t oasis
docker volume create ssb
docker run --mount source=ssb,target=/root/.ssb -p 3000:3000 --rm oasis
```
## Resources
- [Contributing](https://github.com/fraction/oasis/blob/master/docs/contributing.md)

5
server.js Normal file
View File

@ -0,0 +1,5 @@
const ssbConfig = require('ssb-config')
const flotilla = require('@fraction/flotilla')
const server = flotilla({ ws: { http: false } })
server(ssbConfig)

View File

@ -1,11 +1,7 @@
'use strict'
const debug = require('debug')('oasis')
const flotilla = require('@fraction/flotilla')
const ssbClient = require('ssb-client')
const ssbConfig = require('ssb-config')
const server = flotilla({ ws: { http: false } })
const rawConnect = () => new Promise((resolve, reject) => {
ssbClient({
@ -82,9 +78,7 @@ const handle = new Promise((resolve) => {
}).catch(() => {
debug('Initial connection attempt failed')
debug('Starting Scuttlebutt server')
server(ssbConfig)
require('../../../../server')
const connectOrRetry = () => {
rawConnect().then((ssb) => {
debug('Retrying connection to own server')