dao-xyz / peerbit

P2P database framework with encryption, sharding and search
https://peerbit.org
Apache License 2.0
196 stars 15 forks source link

`peerbit-server`: NGINX and Lets Encrypt server without Docker #211

Open marcus-pousette opened 1 year ago

marcus-pousette commented 1 year ago

Remove usage of docker for hosting the server that does NGINX and Lets Encrypt updates

Azaeres commented 1 year ago

To what extent is peerbit-server dockerized? Or is planned to be? Since bootstrapping appears to work with Peerbit, is peerbit-server any different from a libp2p-relay container?

In the case where certs are managed by another container, the following Dockerfile might be a place to start:

FROM node:20-alpine3.18 as builder

ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}

RUN apk --no-cache add make cmake g++ git openssl-dev musl-dev
RUN yarn add @peerbit/server

FROM node:20-alpine3.18

WORKDIR /app
COPY --from=builder node_modules node_modules

COPY . .

CMD ["peerbit", "start"]
EXPOSE 8082

Not sure which ports to expose yet, as the Peerbit documentation could be out of date in this regard. Thoughts?

marcus-pousette commented 1 year ago

To what extent is peerbit-server dockerized?

Peerbit is running a Let Encrypt cert bot in a container, which also bundles a NGINX server (jonasal/nginx-certbot)

This enables two things

The container is started here

This method is invoked from the Server CLI whenever you want to have a domain. See here e.g. when you call

peerbit domain test

you will launch a container with NGINX and Lets encrypt certbot

Since bootstrapping appears to work with Peerbit, is peerbit-server any different from a libp2p-relay container

The difference is about connectivity. A server needs a domain and SSL certificate to be reachable from a browser. So there is a utility for that in the server package. But the problem with that, is that whenever you want to use the server with a domain in a fresh ubuntu env (or any other OS). You need to have docker installed. If you don't need to be reachable from browsers, then you dont need NGINX and a valid SSL Certificate

And the issue now was that for some reason the container randomly shutdown and the logs in the container did not help that much...

apk --no-cache add make cmake g++ git openssl-dev musl-dev yarn add @peerbit/server

It would be cool if yarn add @peerbit/server install all necessary dependencies for running a server with auto renewal of certificates and also installs a NGINX server with some up to date version. Or, an altenrative there would be a clear list of dependencies a user needs to install in order to run their server with NGINX and a Certbot

Aside from that, this Docker file could be a good template if you want to run the whole Peerbit node in a container. Which can be very useful for some usecases!

marcus-pousette commented 1 year ago

Just additional information