Skip to content
On this page

Deployment

Docker Container Deployment

Docker Container Deployment is the easiest way to deploy QD.

Please always remember to back up your database before updating or redeploying.

Container

DockerHub URL : https://hub.docker.com/r/qdtoday/qd

Tag meaning:

  • latest: Latest Release version
  • lite-latest: Latest Release version without OCR related functions
  • ja3-latest: Integrated curl-impersonate to solve the problem that ja3 fingerprint is identified as curl, does not support http3 and Quic connection
  • 20xxxxxx: Specify Release version, version number is represented by Release release date
  • dev: Latest development version, synchronized with the latest source code, no stability guarantee

Deploy Method

1. Docker Compose (Recommend)

sh
# Create and switch to the QD directory.
mkdir -p $(pwd)/qd/config && cd $(pwd)/qd
# Download docker-compose.yml
wget https://fastly.jsdelivr.net/gh/qd-today/qd@master/docker-compose.yml
# Modify the configuration environment variables according to the requirements and configuration description
vi ./docker-compose.yml
# Execute Docker Compose command
docker-compose up -d

See Configuration below for configuration description

If you don't need OCR or hard disk space is not larger than 600M, please use qdtoday/qd:lite-latest image, this image only removes OCR related functions, other than the mainline version to keep consistent.

Please don't use AliCloud image source to pull Docker container, it will not pull the latest image.

2. 1Panel Deployment

2.1. Create a new application in 1Panel

Click to install

The QD framework name may be different in different 1Panel versions, but they are all QD icons.

2.2. Configure related settings

Installation configuration

If you need to set environment variables, please click Edit Compose file

See Configuration below for configuration description

If you don't need OCR or hard disk space is not larger than 600M, please use qdtoday/qd:lite-latest image, this image only removes OCR related functions, other than the mainline version to keep consistent.

2.3. Click Confirm to install QD via 1Panel

3. Docker Run

sh
docker run -d --name qd -p 8923:80 -v $(pwd)/qd/config:/usr/src/app/config qdtoday/qd

Try this command if you cannot connect to the external network inside the container:

sh
# Create container using Host network mode, port: 8923
docker run -d --name qd --env PORT=8923 --net=host -v $(pwd)/qd/config:/usr/src/app/config qdtoday/qd

Please note that after creating a container with this command, please change the api request of http://localhost/ form in the template to api:// or http://localhost:8923/ manually in order to complete the related API request properly.

Do not run both old and new versions of QD framework, or map different running QD container databases to the same file.

Source Code Deployment

  1. Version >= python3.9

    sh
    # Please cd to the root of the framework source code first
    pip3 install -r requirements.txt
  2. Modify the configuration

    sh
    # Execute the following command to copy the configuration file
    # Modifying the content of the local_config.py file is not affected by updating the source code through git
    cp config.py local_config.py
    # Modify the configuration environment variables according to the requirements and configuration description
    vi local_config.py
  3. Run

    sh
    python ./run.py
  4. Access

    sh
    # Access the web page
    http://localhost:8923/

    If you are using the source code deployment method, please change the api request of http://localhost/ form in the template to api:// or http://localhost:8923/ manually in order to complete the related API request properly.

    Templates need to be published to be displayed in "Public Templates", and you need admin rights to approve them in "My Publish Requests".

Configure administrators

sh
python ./chrole.py your@email.address admin

The first registered user is the administrator by default, you need to log out and then login to get full administrator rights

Configuration Environment Variables

variable namerequireddefault valuedescription
BINDNo0.0.0.0Listening address
PORTNo8923Listening port
QD_DEBUGNoFalseWhether to enable Debug mode
WORKER_METHODNoQueueTask timing execution method,
The default is Queue, optional Queue or Batch,
Batch mode is the old version of timing task execution method, the performance is weak,
Recommended only when Queue timed execution mode fails
MULTI_PROCESSNoFalse(Experimental) Whether to enable multi-process mode,
invalid on Windows platform
AUTO_RELOADNoFalseWhether to enable automatic hot reload,
invalid when MULTI_PROCESS=True
STATIC_URL_PREFIXNo/static/Static file URL prefix
DOMAINNo''Specify the access domain name,
(recommended modification), otherwise the function of resetting password by email is not valid
AES_KEYNobinuxAES encryption key, (Modification strongly recommended)
COOKIE_SECRETNobinuxcookie encryption key, (Modification strongly recommended)
COOKIE_DAYNo5The number of days the cookie is kept in the client
DB_TYPENosqlite3Set to 'mysql' when MySQL is required
JAWSDB_MARIA_URLNo''When you need to use MySQL,
set to mysql://username:password@hostname:port/database_name?auth_plugin=
QD_SQL_ECHONoFalseWhether to enable the log output of SQLAlchmey, the default is False,
When set to True, the SQL statement will be output on the console,
allow to set to debug to enable debug mode
QD_SQL_LOGGING_NAMENoQD.sql_engineSQLAlchmey log name, default is 'QD.sql_engine'
QD_SQL_LOGGING_LEVELNoWarningSQLAlchmey log level, default is 'Warning'
QD_SQL_ECHO_POOLNoTrueWhether to enable SQLAlchmey's connection pool log output, the default is True,
allow setting to debug to enable debug mode
QD_SQL_LOGGING_POOL_NAMENoQD.sql_poolSQLAlchmey connection pool log name, the default is 'QD.sql_pool'
QD_SQL_LOGGING_POOL_LEVELNoWarningSQLAlchmey connection pool log level, default is 'Warning'
QD_SQL_POOL_SIZENo10SQLAlchmey connection pool size, default is 10
QD_SQL_MAX_OVERFLOWNo50SQLAlchmey connection pool maximum overflow, the default is 50
QD_SQL_POOL_PRE_PINGNoTrueWhether to ping before the connection pool gets a connection, the default is True
QD_SQL_POOL_RECYCLENo3600SQLAlchmey connection pool recovery time, the default is 3600
QD_SQL_POOL_TIMEOUTNo60SQLAlchmey connection pool timeout, the default is 60
QD_SQL_POOL_USE_LIFONoTrueSQLAlchmey whether to use LIFO algorithm, the default is True
REDISCLOUD_URLNo''When you need to use Redis or RedisCloud,
set to http://rediscloud:password@hostname:port
REDIS_DB_INDEXNo1The default is 1
QD_EVILNo500(Only when the Redis connection is enabled)
Score = number of operation failures (such as login, verification, test, etc.) * corresponding penalty points
When the score reaches the upper limit of evil, it will be automatically banned until the next hour cycle
EVIL_PASS_LAN_IPNoTrueWhether to turn off the evil restriction of local private IP address users and Localhost_API requests
TRACEBACK_PRINTNoFalseWhether to enable to print Exception's TraceBack information in the console log
PUSH_PIC_URLNopush_pic.pngThe default is [push_pic.png](https 😕/fastly.jsdelivr.net/gh/qd-today/qd@master/web/static/img/push_pic.png)
PUSH_BATCH_SWNoTrueWhether to allow periodic push of QD task logs, the default is True
MAIL_SMTPNo""Email SMTP server
MAIL_PORTNo465Email SMTP server port
MAIL_SSLNoTrueWhether to use SSL when connecting to the email server, the default is True
MAIL_STARTTLSNoFalseWhether to use TLS when connecting to the email server, the default is False
MAIL_USERNo""Email username
MAIL_PASSWORDNo""Email password
MAIL_FROMNoMAIL_USERThe Email used when sending, the default is the same as MAIL_USER
MAIL_DOMAIN_HTTPSNoFalseWhether to use HTTPS for email domain name.
Not the framework itself HTTPS configuration.
If you need HTTPS, please use an external reverse proxy
PROXIESNo""Global proxy domain name list, separated by "|"
PROXY_DIRECT_MODENo""Global proxy blacklist mode, not enabled by default
"url" is URL matching mode; "regexp" is regular expression matching mode
PROXY_DIRECTNo""Global proxy blacklist matching rules
NEW_TASK_DELAYNo1Preparation time after new task, default is 1 second
TASK_WHILE_LOOP_TIMEOUTNo900Maximum runtime of a single While loop during a task run,
the default is 15 minutes
TASK_REQUEST_LIMITNo1500Maximum number of requests per task run,
the default is 1500
USE_PYCURLNoTrueWhether to enable Pycurl module
ALLOW_RETRYNoTrueWhen some requests in the Pycurl environment may cause Request errors,
automatically modify the conflict settings and resend the request
DNS_SERVERNo""Use specified DNS for resolution via Curl (only supports Pycurl environment),
such as 8.8.8.8
CURL_ENCODINGNoTrueWhether to allow to use Curl for Encoding operation
CURL_CONTENT_LENGTHNoTrueWhether to allow Curl to use custom Content-Length request in Headers
NOT_RETRY_CODENoSee configuration for details...See configuration for details...
EMPTY_RETRYNoTrueSee configuration for details...
USER0ISADMINNoTrueThe first registered user is an administrator, False to close
NOTEPAD_LIMITNo20The maximum number of notepads within the same user, the default is 20
EXTRA_ONNX_NAMENo""Customize the ONNX file name in the config directory
(do not fill in the ".onnx" suffix)
Separate multiple onnx file names with "|"
EXTRA_CHARSETS_NAMENo""Custom ONNX in the config directory corresponds to the custom charsets.json file name
(do not fill in the ".json" suffix)
Multiple json file names are separated by "|"
WS_PING_INTERVALNo5WebSocket ping interval, the default is 5 seconds
WS_PING_TIMEOUTNo30WebSocket ping timeout, the default is 30 seconds
WS_MAX_MESSAGE_SIZENo10485760WebSocket maximum message size, the default is 10485760 bytes
WS_MAX_QUEUE_SIZENo100WebSocket maximum queue size, the default is 100
WS_MAX_CONNECTIONS_SUBSCRIBENo30WebSocket subscribe page maximum number of connections, the default is 30
SUBSCRIBE_ACCELERATE_URLNojsdelivr_cdnSubscribe page acceleration URL, the default is jsdelivr_cdn,
See configuration for details...

For details, please refer to config.py

Released under the MIT License.