Skip to content

Commit

Permalink
Support for "One-click" releases (#205)
Browse files Browse the repository at this point in the history
* Refactored start docs

* Changed source of go-bindata #197

* Updated go dep trackers

* Updated yarn dependencies

* Added update step to Makefile

* New auto-generated bindata tests

* Added doc note about make update

* yarn upgrade

* Doc: rename Infura key as "project ID" for clarity

* Set resource class to medium for CircleCI builds

* Use Debian 'stable' release in Docker

* Added bootstrap

* Added stackscript

* Default branch

* Added variables

* Root folder

* Stackscript updated

* StackScript README

* Revert to master yarn.lock

* Stackscript and Readme

* Added virtual host to StackScript

* Switch to official bootstrap source
  • Loading branch information
loleg authored Mar 12, 2021
1 parent ac1c806 commit e3a101e
Show file tree
Hide file tree
Showing 4 changed files with 292 additions and 6 deletions.
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,33 @@

# Proxeus
----------------
Main repository of the proxeus platform.
Main repository of the Proxeus platform core.

Proxeus combines a powerful document automation tool with the wide-ranging
blockchain functionalities, enabling users to digitize and monetize their IP.

## Source Code
You can access the source code of this application and various extensions
on [GitHub](https://github.com/ProxeusApp).

You can access the source code of this application on the [Proxeus GitHub repository](https://github.com/ProxeusApp).
# Quick Starts

## Quick Start with docker
The quickest way to try Proxeus is to use `docker-compose`.
## One-click builds

We are making facilitated build configurations available for select cloud platforms:

- [Linode StackScript](deploy/linode/README.md)

## Using Docker

The quickest way to set up Proxeus for development is to use Docker, and the `docker-compose` tool.

### Install docker and docker-compose

1. [Install Docker Engine](https://docs.docker.com/install/)
2. [Install docker-compose](https://docs.docker.com/compose/install/)

### Get API Keys for Infura and SparkPost

The Proxeus platform depends on [Infura](https://infura.io/) and [SparkPost](https://www.sparkpost.com/)
for Ethereum and email integration respectively.

Expand All @@ -41,7 +51,7 @@ Proxeus platform.

## User manual

The user manual is available here: [User Manual](https://docs.google.com/document/d/1SP0ZimG7uemfZ2cF2JkY5enUZnBJLDyfcJGZnyWOejQ)
Get help to make the most of the platform in the [User Handbook](https://docs.google.com/document/d/e/2PACX-1vTchv7PotoQeH2cBA2VIHcqV0I0N_IQpFnbESR-8C19cgBikek3HAMVdPtfJJcYkANzPWbfy_S3bf8X/pub).

## Contributing

Expand Down
120 changes: 120 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $TRACE ]] && set -x

# A script to bootstrap proxeus-core.

# Based on https://github.com/dokku/dokku/blob/master/bootstrap.sh
# We encourage you to also add Dokku for managing your instance,
# however this is not done by this script.

# It expects to be run on Debian, Ubuntu, or CentOS 7 via 'sudo'

# It checks out the proxeus source code from Github into ~/proxeus and then runs 'make install'.


log-fail() {
declare desc="log fail formatter"
echo "$@" 1>&2
exit 1
}

ensure-environment() {
local FREE_MEMORY
if [[ -z "$GIT_TAG" ]]; then
echo "Preparing to install $GIT_REPO..."
else
echo "Preparing to install $GIT_TAG from $GIT_REPO..."
fi

hostname -f >/dev/null 2>&1 || {
log-fail "This installation script requires that you have a hostname set for the instance. Please set a hostname for 127.0.0.1 in your /etc/hosts"
}

if ! command -v apt-get &>/dev/null; then
log-fail "This installation script supports Debian-based systems and expects apt-get."
fi

if ! command -v docker &> /dev/null; then
log-fail "Docker needs to be installed."
fi

if ! command -v docker-compose &> /dev/null; then
log-fail "Docker Compose needs to be installed."
fi

FREE_MEMORY=$(grep MemTotal /proc/meminfo | awk '{print $2}')
if [[ "$FREE_MEMORY" -lt 1003600 ]]; then
echo "To build containers, it is strongly suggested that you have 1024 megabytes or more of free memory"
fi
}

install-requirements() {
echo "--> Ensuring we have the proper dependencies"

case "$SRV_DISTRO" in
debian)
if ! dpkg -l | grep -q software-properties-common; then
apt-get update -qq >/dev/null
apt-get -qq -y --no-install-recommends install software-properties-common
fi
;;
ubuntu)
if ! dpkg -l | grep -q software-properties-common; then
apt-get update -qq >/dev/null
apt-get -qq -y --no-install-recommends install software-properties-common
fi

add-apt-repository universe >/dev/null
apt-get update -qq >/dev/null
;;
esac

apt-get -qq -y --no-install-recommends install sudo git make software-properties-common
}

install-proxeus() {
if [[ -n $GIT_BRANCH ]]; then
install-proxeus-from-source "origin/$GIT_BRANCH"
elif [[ -n $GIT_TAG ]]; then
local GIT_SEMVER="${GIT_TAG//v/}"
major=$(echo "$GIT_SEMVER" | awk '{split($0,a,"."); print a[1]}')
minor=$(echo "$GIT_SEMVER" | awk '{split($0,a,"."); print a[2]}')
patch=$(echo "$GIT_SEMVER" | awk '{split($0,a,"."); print a[3]}')

install-proxeus-from-source "$GIT_TAG"
else
install-proxeus-from-source
fi
}

install-proxeus-from-source() {
local GIT_CHECKOUT="$1"

if [[ ! -d ./proxeus ]]; then
git clone "$GIT_REPO" ./proxeus
fi

cd ./proxeus
git fetch origin
[[ -n $GIT_CHECKOUT ]] && git checkout "$GIT_CHECKOUT"
make
}

main() {
export SRV_DISTRO SRV_DISTRO_VERSION
# shellcheck disable=SC1091
SRV_DISTRO=$(. /etc/os-release && echo "$ID")
# shellcheck disable=SC1091
SRV_DISTRO_VERSION=$(. /etc/os-release && echo "$VERSION_ID")

export DEBIAN_FRONTEND=noninteractive
export GIT_REPO=${GIT_REPO:-"https://github.com/ProxeusApp/proxeus-core.git"}

ensure-environment
install-requirements
install-proxeus
}

main "$@"

26 changes: 26 additions & 0 deletions deploy/linode/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Proxeus StackScript for fast Linode deployment
---

Creates a compact all-in-one instance of the Proxeus application (no code environment for smart contracts) using a bootstrapped release image for Docker. This is a good starting point for development or small installations. For more information visit https://github.com/ProxeusApp

StackScripts are private or public managed scripts which run within a Linode instance during startup. Using a simple form, you can configure the basic details needed to quickly get a Proxeus instance up and running.

This script is maintained for the community by Proxeus Association

## Instructions

1. Search for "proxeus" when deploying a new Linode, or log in and navigate to https://cloud.linode.com/stackscripts/758453
1. Additional documentation is available from [Linode Guides](https://www.linode.com/docs/guides/platform/stackscripts/)
1. You will need to have your API keys for Infura and Sparkpost handy - see the root README for further details.
1. It takes a few minutes for the server to boot and install, then you should be able to open `http://<your Linode's IP address or domain>:1323/init`
1. A configuration screen will be shown where you can set up an admin account and check settings.

Once your server is running, visit the [User Handbook](https://docs.google.com/document/d/e/2PACX-1vTchv7PotoQeH2cBA2VIHcqV0I0N_IQpFnbESR-8C19cgBikek3HAMVdPtfJJcYkANzPWbfy_S3bf8X/pub) to get started.

## References

The basic set-up of a Debian or Ubuntu server is based roughly on Linode's [Basic OCA Helper One-Click](https://cloud.linode.com/stackscripts/401712).

We suggest [Securing Public Shadowsocks Server](https://github.com/shadowsocks/shadowsocks/wiki/Securing-Public-Shadowsocks-Server) as one example guide to follow for further 'buttoning down' your instance.

[Linode](https://linode.com) is a privately-owned American cloud hosting company that provides virtual private and managed servers around the world.
130 changes: 130 additions & 0 deletions deploy/linode/stackscript.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#!/bin/bash

# <UDF name="FQDN" Label="Fully Qualified Domain Name" example="web.example.com" />
# <UDF name="INFURA" Label="Infura.io API key" example="a0e728c9fd444a123456789000b9370f" />
# <UDF name="SPARKPOST" Label="Sparkpost.com API key" example="27ed8e1234567890000014863f9e2cf553a7bd87" />

# Logs: tail -f /var/log/stackscript.log
# Logs: cat /var/log/stackscript.log

# Log to /var/log/stackscript.log for future troubleshooting

# Logging set up
exec 1> >(tee -a "/var/log/stackscript.log") 2>&1
function log {
echo "### $1 -- `date '+%D %T'`"
}

# Common bash functions
source <ssinclude StackScriptID=1>
log "Common lib loaded"

# Apply harden script
source <ssinclude StackScriptID=394223>
log "Hardening activated"

log "Configuring System Updates"
apt-get -o Acquire::ForceIPv4=true update -y
DEBIAN_FRONTEND=noninteractive apt-get -y -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" install grub-pc
apt-get -o Acquire::ForceIPv4=true update -y

## Set hostname, configure apt and perform update/upgrade
log "Setting hostname"
IP=`hostname -I | awk '{print$1}'`
hostnamectl set-hostname $FQDN
echo $IP $FQDN >> /etc/hosts

log "Updating .."
export DEBIAN_FRONTEND=noninteractive
apt-get update -y

## Remove older installations and get set for Docker install
log "Getting ready to install Docker"
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
make \
gnupg-agent \
software-properties-common \
apache2-utils

log "Installing Docker Engine for $lsb_dist"
lsb_dist="$(. /etc/os-release && echo "$ID")"
lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')"

## Add Docker’s official GPG key
curl -fsSL "https://download.docker.com/linux/$lsb_dist/gpg" | sudo apt-key add -

## Install stable docker as daemon
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/$lsb_dist \
$(lsb_release -cs) \
stable"
apt-get update
apt-get install -y docker-ce docker-ce-cli docker-compose containerd.io
systemctl enable docker

## Set up fail2ban
log "Installing fail2ban"
apt-get install fail2ban -y
cd /etc/fail2ban
cp fail2ban.conf fail2ban.local
cp jail.conf jail.local
systemctl start fail2ban
systemctl enable fail2ban

## Set up firewall with port 1323 open to default Proxeus platform
# Set up nginx separately to proxy to 443
log "Configuring firewall"
apt-get install ufw -y
ufw default allow outgoing
ufw default deny incoming

ufw allow ssh
ufw allow https
ufw allow http
ufw allow 1323

ufw enable

systemctl enable ufw
ufw logging off

## ----------------------------------------------
## Install & configure proxeus

log "Installing Proxeus"
mkdir -p /srv
cd /srv

wget https://raw.githubusercontent.com/ProxeusApp/proxeus-core/master/bootstrap.sh;
bash bootstrap.sh

cd proxeus
cat <<END >.env
PROXEUS_BLOCKCHAIN_CONTRACT_ADDRESS=0x1d3e5c81bf4bc60d41a8fbbb3d1bae6f03a75f71
PROXEUS_ALLOW_HTTP=true
PROXEUS_DATA_DIR=./data
PROXEUS_INFURA_API_KEY=$INFURA
PROXEUS_SPARKPOST_API_KEY=$SPARKPOST
PROXEUS_PLATFORM_DOMAIN=http://$FQDN:1323
PROXEUS_VIRTUAL_HOST=$FQDN
END

log "Starting Proxeus Core"
docker-compose up -d &

# In a production setting you might want to use a separate env file and/or overrides
# docker-compose --env-file .env.prod -f docker-compose.yml -f docker-compose-cloud.override.yml up -d &


# Open http://$FQDN:1323/init to configure your server
log "After a minute, open: http://$FQDN:1323/init"

## ----------------------------------------------

echo "Installation complete!"

0 comments on commit e3a101e

Please sign in to comment.