Warning: The purpose of this project is to be simple to run, with very few configuration steps. There is no intent to make it 100% secure, infinitely scalable, or suitable for a live production app handling real Pi on the mainnet. Use it at your own risk and customize it as needed to improve security and scalability.
The production deployment uses docker-compose, and needs to run 4 containers:
The following setup process was tested on Ubuntu Server 22.04.1. You may need to adapt it to your own needs depending on your distro (specifically, the “Install Docker” step).
It assumes you’re running as root. If that’s not the case, prepend all commands with sudo
or start
a root shell with sudo bash
.
Run the following command in order to get the latest docker version and the latest docker-compose version (required because of this issue)
apt-get update && \
apt-get install -y zip apt-transport-https ca-certificates curl gnupg-agent software-properties-common && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" && \
apt-get update && \
apt-get install -y docker-ce docker-ce-cli containerd.io && \
curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && \
chmod +x /usr/local/bin/docker-compose
Obtain a domain name and set up 2 DNS records pointing to your server. One will be used for the frontend app, and one will be used for the backend app.
Here is an example, assuming your domain name is mydemoapp.com and your server IP is 123.123.123.123.
A mydemoapp.com 123.123.123.123
A backend.mydemoapp.com 123.123.123.123
Open develop.pi
in the Pi Browser, on your mobile phone, and go through the prerequisite steps
(e.g verifying your email address).
Two options here:
Register an App:
This will bring you to the App Dashboard, from this screen you can continue the setup of the demo app for deployment.
Create a .env config file in order to enable docker-compose to pick up your environmnent variables:
# Move to the app's directory:
cd platform-demo-app
# Create .env from the starter template:
cp .env.example .env
# Edit the resulting file:
vi .env
# or:
nano .env
Set up the following environment variables. Using the example above:
FRONTEND_URL=https://mydemoapp.com
FRONTEND_DOMAIN_NAME=mydemoapp.com
BACKEND_URL=https://backend.mydemoapp.com
BACKEND_DOMAIN_NAME=backend.mydemoapp.com
Obtain the following values from the developer portal:
Domain Verification Key: Go to the developer portal, and on your list of registered apps click on the app you are verifying. Next click on the “App Checklist” and click on step 7. From this page you can obtain the string that needs added to your .env
file.
API key: obtained by tapping the “API Key” button on the App Dashboard
Then, copy-paste those values in the following two keys of your .env file:
# Add your Domain Validation Key here:
DOMAIN_VALIDATION_KEY=
# Add your API key here:
PI_API_KEY=
Configure the following environment variables:
# Generate a secure password for your MongoDB database and paste it here:
MONGODB_PASSWORD=
# Generate a random string (e.g 64 alphanumeric characters) and paste it here:
SESSION_SECRET=
Make sure you are in the platform-demo-app
directory before running any docker-compose
command!
docker-compose build
docker-compose up -d
You can check which containers are running using either one of the following two commands:
docker ps
docker-compose ps
You can print out logs of the Docker containers using the following command:
docker-compose logs -f <service-name>
# e.g:
docker-compose logs -f reverse-proxy
Go to the developer portal, and on your list of registered apps click on the app you are verifying. While the app is deployed, click on the “Verify Domain” button. This should verify your frontend domain and mark it as verified (green check mark on the developer portal).
Open your frontend app’s URL in the developer portal and make sure everything works by signing it and placing an order, then proceeding with the payment (you will need a testnet wallet in order to complete this step).