Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for "One-click" releases #205

Merged
merged 30 commits into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4816268
Refactored start docs
loleg Apr 24, 2020
1436c38
Changed source of go-bindata #197
loleg Dec 18, 2020
00d6551
Merge branch 'master' of github.com:loleg/proxeus-core
loleg Dec 18, 2020
3660972
Updated go dep trackers
loleg Dec 18, 2020
f3309a2
Updated yarn dependencies
loleg Dec 18, 2020
2872470
Added update step to Makefile
loleg Dec 18, 2020
9313e5c
Merged
loleg Dec 18, 2020
2920a96
New auto-generated bindata tests
loleg Dec 18, 2020
92b576b
Added doc note about make update
loleg Dec 18, 2020
95bf3ef
yarn upgrade
loleg Dec 18, 2020
a97271a
Doc: rename Infura key as "project ID" for clarity
loleg Dec 18, 2020
2a29ecd
Set resource class to medium for CircleCI builds
loleg Dec 18, 2020
3fd9ff2
Use Debian 'stable' release in Docker
loleg Dec 18, 2020
508ebb6
Added bootstrap
loleg Feb 7, 2021
5b6237a
Merge branch 'master' of https://github.com/ProxeusApp/proxeus-core
loleg Feb 7, 2021
750b0ef
Merged
loleg Feb 7, 2021
3478aee
Merged yarn.lock
loleg Feb 7, 2021
9c1baca
Merge branch 'master' of github.com:loleg/proxeus-core
loleg Feb 7, 2021
8276a67
Merge branch 'master' into release
loleg Feb 7, 2021
2b22489
Added stackscript
loleg Feb 9, 2021
06f9288
Default branch
loleg Feb 9, 2021
56250b4
Added variables
loleg Feb 9, 2021
18fdb02
Root folder
loleg Feb 9, 2021
10c594c
Stackscript updated
loleg Feb 10, 2021
0fc1cd8
StackScript README
loleg Feb 10, 2021
be9c44b
Revert to master yarn.lock
loleg Feb 10, 2021
3e7ff8a
Stackscript and Readme
loleg Feb 20, 2021
da2ec04
Added virtual host to StackScript
loleg Mar 12, 2021
d63a17e
Merge remote-tracking branch 'upstream/master' into release
loleg Mar 12, 2021
3255974
Switch to official bootstrap source
loleg Mar 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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!"