Skip to content

Deploy Application

Thanks to Python's powerful cross-platform capabilities, Qexo supports deployment on various platforms. The supported deployment methods are Vercel or Docker. Local source code deployment is only recommended for advanced users.

It is worth noting that if you are using Vercel for deployment, I do not recommend using your own database, as you often cannot guarantee the connection quality with Vercel.

Docker Deployment

It is recommended to use Docker to deploy the Qexo application anywhere with one click.

bash
docker run -d \
    --restart=unless-stopped \
    -v $(pwd)/db:/app/db \
    -p 8000:8000 \
    -e TIMEOUT=600 \
    --name="qexo" \
    abudulin/qexo:latest

Where $(pwd)/db is the data storage directory, you can change it to the desired address.

If you need the Dev branch, please pull qexo:testing.

Of course, you can also use docker-compose.

yml
version: '3.8'

services:
  qexo:
    image: abudulin/qexo:latest
    container_name: qexo
    restart: unless-stopped
    ports:
      - "8000:8000"
    environment:
      WORKERS: 4
      THREADS: 4
      TIMEOUT: 600
    volumes:
      - ./db:/app/db

Vercel Deployment (PostgreSQL/Vercel)

You can use the free database provided by Vercel. But please note that this is a Beta feature.

One-click Deployment

Deploy to Vercel

The first deployment will report an error, please ignore it and proceed to the next steps.

Apply for Vercel Database

Go to the Vercel Storage page and click Create Database in the upper right corner, select Postgres to create a free PostgreSQL database, and get the database connection information on the Connect page. Please note to select the region corresponding to your project in the previous step (usually Washington, D.C., USA (East) - iad1).

Bind Project

Select Projects in the left sidebar and click Connect Project to connect to the project you created in the first step.

Deployment

Go back to your project page, click Redeploy in Deployments to start the deployment. If there is no Error message, you can open the domain to enter the initialization guide.

Vercel Deployment (MySQL/PlanetScale)

The popular database platform PlanetScale has removed the free plan. Developers must pay before April 8.

You can use the free database provided by PlanetScale.

Apply for PlanetScale Database

Register a PlanetScale account to create a free MySQL database (not supported for mainland China IPs). The region must be AWS / N. Virginia (us-east-1), and record the database connection information.

One-click Deployment

Deploy to Vercel

The first deployment will report an error, please ignore it and re-enter the project. Add environment variables in the project settings page.

NameMeaningExample
MYSQL_HOSTMySQL database connection addressus-east.connect.psdb.cloud
MYSQL_PORTMySQL database communication port3306
MYSQL_USERMySQL database usernameabudu
MYSQL_NAMEMySQL database namemydatabase
MYSQL_PASSWORDMySQL database passwordpassword
PLANETSCALE(Optional) Set to 1 if using PlanetScale1

The PLANETSCALE is used to disable foreign key constraints to prevent PlanetScale database deployment failures. If you are using your own database and have no special requirements, do not fill in.

Click Redeploy in Deployments to start the deployment. If there is no Error message, you can open the domain to enter the initialization guide.

Vercel Deployment (PostgreSQL/SupaBase)

You can use the free database provided by SupaBase.

Apply for SupaBase Database

Register a SupaBase account to create a free SupaBase database. The region must be N. Virginia (us-east-1). Get the database connection information on the project settings page. The password is the value you set.

One-click Deployment

Deploy to Vercel

The first deployment will report an error, please ignore it and re-enter the project. Add environment variables in the project settings page.

NameMeaningExample
PG_HOSTPostgreSQL database connection addressdb.xxx.supabase.co
PG_PORTPostgreSQL database communication port5432
PG_USERPostgreSQL database usernamepostgres
PG_DBPostgreSQL database namepostgres
PG_PASSPostgreSQL database passwordpassword

Click Redeploy in Deployments to start the deployment. If there is no Error message, you can open the domain to enter the initialization guide.

Considering that Djongo's support for MongoDB is not perfect, it is recommended to use other databases (MySQL/PostgreSQL).

Apply for MongoDB Database

Register a MongoDB account to create a free MongoDB database. The region must be AWS / N. Virginia (us-east-1). Click CONNECT on the Clusters page, follow the steps to allow connections from all IP addresses, create a database user, and record the database connection information. The password is the value you set.

One-click Deployment

Deploy to Vercel

The first deployment will report an error, please ignore it and re-enter the project. Add environment variables in the project settings page.

NameMeaningExample
MONGODB_HOSTMongoDB database connection addressmongodb+srv://cluster0.xxxx.mongodb.net
MONGODB_PORTMongoDB database communication port27017
MONGODB_USERMongoDB database usernameabudu
MONGODB_DBMongoDB database nameCluster0
MONGODB_PASSMongoDB database passwordpassword

Click Redeploy in Deployments to start the deployment. If there is no Error message, you can open the domain to enter the initialization guide.

Local Source Code Deployment (Advanced)

Starting from version 2.0, Qexo has provided more comprehensive support for local deployment.

Due to the diversity and uncertainty of local deployment issues, the maintainers cannot guarantee effective support. General users are recommended to use Docker deployment. Source code deployment is only recommended for advanced users who need to configure the local Python3 environment by themselves.

If you want to use local deployment, please use version 2.0+ or the Dev branch.

Download Release

Download the latest version Source code (zip) from Release and unzip it.

Prepare Database

Refer to the Django official documentation.

Official SupportThird-party Support
PostgreSQLCockroachDB
MariaDBFirebird
MySQLGoogle Cloud Spanner
OracleMicrosoft SQL Server
SQLite......

Note 1: You may need to modify requirement.txt to install dependencies according to the database you use.

Note 2: During one-click updates, files in the directory named db and the file named configs.py will not be deleted. You should place important files (such as databases) in this folder.

Edit Configuration

Take using MySQL as an example. After confirming the installation of related dependencies, create and modify configs.py in the same directory as manage.py.

python
import pymysql
pymysql.install_as_MySQLdb()
DOMAINS = ["127.0.0.1", "yoursite.com"]
DATABASES = {
    'default': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME': 'qexo',
            'USER': 'root',
            'PASSWORD': 'password',
            'HOST': '127.0.0.1',
            'PORT': '3306',
            'OPTIONS': {
                "init_command": "SET sql_mode='STRICT_TRANS_TABLES'"
            }
    }
}

If you need to import other libraries or execute code in init.py, you can directly write import pymysql at the top.

Execute Commands to Run

bash
pip3 install -r requirements.txt
python3 manage.py makemigrations
python3 manage.py migrate
python3 manage.py runserver 0.0.0.0:8000 --noreload

For a production environment, it is recommended to switch to uWSGI or Gunicorn.

Released under the GPL3.0 License.