Hey, guys have been playing around with Docker and it’s possible to create a lightweight Safe node using alpine (light Linux distro) and some dependencies + the installation script from the maidsafe GitHub.
Docker runs images inside of containers and this makes running it on any OS very simple. You only need to install docker which is widely available and optionally build from the source or download a generated docker image and directly run it. Some NAS like Synology also supports running docker images so it will directly spin up a Safe Node on your NAS if it supports it!
Steps to do:
- Install docker on your operating system
- Create a folder with a project name
- Copy the following code to the file that will be called ‘dockerfile’
# Build SafeNetwork Docker container FROM alpine:latest LABEL version="0.1" LABEL maintainer="DeusNexus" LABEL release-date="2021-01-31" # Update and install dependencies RUN apk update RUN apk add bash #unix shell to run install script RUN apk add curl #cUrl to transfer data #Make profile file with exported PATH and refresh the shell (while building) SHELL ["/bin/bash", "--login", "-c"] RUN echo 'export PATH=$PATH:/root/.safe/cli' > ~/.profile && source ~/.profile #Set ENV PATH (after build will be used to find 'safe') ENV PATH=$PATH:/root/.safe/cli #Installation Script - MaidSafe installation script RUN curl -so- https://sn-api.s3.amazonaws.com/install.sh | bash #Install Safe - During Build RUN safe node install RUN safe auth install #Expose PORT of the node EXPOSE 12000 #Run command on Docker launch CMD ["safe"]
- Build the docker image with
docker build -t safe_node .while in the project folder with the
dockerfile(My image is built with Docker version 20.10.2, build 2291f61)
This will download all the dependencies and use the installation script to install safe.
- After the image is built you can spin it up any time using
docker run -it safe_node.
It will open up into the safe_cli interface, you can use
--helpto see the commands. Just note that I’m still fixing some bugs bug in general it seems to be decently working.
Things to add are a
VOLUME basically the external mounting point that the docker image will use to store data and make the data persistent!
Cool things possible to add are simple HTTP GUI that could restart the server with buttons, display the state, and various things using express server and exposed apache server.