Skip to main content

Introduction

  • This article guides you through creating and hosting a PG Admin application on Square Cloud.
  • Before getting started, make sure you have an account on Square Cloud, which can be done through the sign up page. You can use your email to create an account.
  • Finally, you need to have an active paid plan on your account. You can view our plans and purchase one according to your needs here.

Creating the Project

  • First of all we need an Python environment. To do this, we need a requirements.txt or a pyproject.toml. You can see how to create a requirements.txt here.
  • Your requirements.txt must have pgadmin4 and a webserver to serve it. In this tutorial, we will use gunicorn.
requirements.txt
pgadmin4
gunicorn
  • Next, you will need a config file config_local.py to set some paths. These paths will define where to save some infos about your pgadmin.
config_local.py
SERVER_MODE = True
MAX_LOGIN_ATTEMPTS = 3
"""
    CRITICAL 50
    ERROR    40
    WARNING  30
    SQL      25
    INFO     20
    DEBUG    10
    NOTSET    0
"""
CONSOLE_LOG_LEVEL = 10
DATA_DIR = "/application/.pgadmin/"
LOG_FILE = "/application/.pgadmin/logfile"
SQLITE_PATH = '/application/.pgadmin/pgadmin4.db'
We already have everything ready for deploy on our repository here. You just need to download the project.zip and upload it.

📁 Necessary Files

The following files are necessary in your zip:
  • requirements.txt or pyproject.toml
  • .env (optional)

⚙️ Configuration File

  • You need to configure runtime environment to Detect manually and set it to NodeJS. In a squarecloud.config or squarecloud.app will look like this:
squarecloud
DISPLAY_NAME=App name
RUNTIME=python
MEMORY=1024
START=python -m gunicorn --bind 0.0.0.0:80 --workers=1 --threads=4 pgadmin4.pgAdmin4:app
VERSION=recommended
SUBDOMAIN=my-pgadmin-subdomain
  • Next, we need to set 2 environment variables, PGADMIN_SETUP_EMAIL and PGADMIN_SETUP_PASSWORD in a .env file or in the Square Cloud environment on the upload menu.
.env
PGADMIN_SETUP_EMAIL=accessemail@example.com
PGADMIN_SETUP_PASSWORD=yourSecurePassword

Uploading the Project to Square Cloud

After preparing your project files, you can now upload them to Square Cloud and host your project.
  • Upload via Dashboard
  • Upload via CLI
Access the Square Cloud Dashboard and upload your project files.