Sign inSign up

mountaincnc/read

By mountaincnc

•Updated 6 months ago

unofficial image for https://github.com/autobcb/read

Image
0

6.7K

mountaincnc/read repository overview

⁠Application Overview

The core application is a Java program (read.jar) that appears to be a web service or application. The use of the Solon framework suggests a focus on being lightweight and high-performing.

⁠Configuration Management

The application's configuration is managed dynamically through a docker-entrypoint.sh script. This script's primary role is to generate a conf.yml file based on environment variables if an external configuration file is not mounted.

⁠Key Configuration Areas (via Environment Variables)
  • Database (DB_*): You can configure the application to use either a MySQL or SQLite database. For MySQL, you can specify the host, port, database name, username, and password. If MySQL is not specified, it defaults to a local SQLite database.
  • Caching (CACHE_*): The application can be configured to use Redis for caching by setting CACHE_DRIVERTYPE to "redis". You can also specify the Redis server address and other connection parameters.
  • Admin User (ADMIN_*): You can set the username and password for the administrative user.
  • User Settings (USER_*): Various user-level permissions and settings can be configured, such as allowing text uploads, caching, and image uploads.
  • SMTP (SMTP_*): For email functionality, you can configure the SMTP server details, including host, port, credentials, and email templates for verification codes.
  • Server Performance (SERVER_HTTP_*): You can adjust the core and maximum number of HTTP threads.
  • Proxy (PROXY_*): The application can be started with an HTTP/S proxy by setting the PROXY_HOST and PROXY_PORT environment variables.
⁠Configuration Precedence

It is IMPORTANT to note that if you mount an external configuration file at /app/conf.yml, the docker-entrypoint.sh script will use it directly, and the environment variables related to the application's configuration will be ignored.

⁠Database Configuration

These variables control the database connection. The application defaults to SQLite if DB_TYPE is not set to mysql.

VariableDescriptionDefault Value
DB_TYPESpecifies the database type. Set to mysql to use MySQL.(none, defaults to SQLite)
DB_HOSTThe hostname or IP of the MySQL server.127.0.0.1
DB_PORTThe port for the MySQL server.3306
DB_DATABASEThe name of the database to use.(none)
DB_USERNAMEThe username for the database connection.(none)
DB_PASSWORDThe password for the database connection.(none)

⁠Cache Configuration

This configuration block is only added if CACHE_DRIVERTYPE is set to redis.

VariableDescriptionDefault Value
CACHE_DRIVERTYPEThe cache driver to use. Set to redis to enable Redis.(none)
CACHE_KEYHEADERA prefix for all cache keys stored in Redis.read
CACHE_DEFSECONDSThe default cache expiration time in seconds.600
CACHE_SERVERThe Redis server address (e.g., redis:6379).localhost:6379
CACHE_PASSWORDThe Redis database password.(none)
CACHE_DBThe Redis database number to connect to.0
CACHE_IDELCONNECTIONTIMEOUTThe idle connection timeout for Redis in milliseconds.10000
CACHE_CONNECTTIMEOUTThe connection timeout for Redis in milliseconds.10000

⁠Admin & User Configuration

These variables control administrative access and default user permissions.

VariableDescriptionDefault Value
ADMIN_USERNAMEThe username for the application's admin account.admin
ADMIN_PASSWORDThe password for the application's admin account.adminadmin
ADMIN_CODEThe code for the application's invitation code parameter.invite
USER_ALLOWUPTXTWhether to allow users to upload text (true/false).false
USER_ALLOWCACHEWhether to allow users to use the cache feature (true/false).false
USER_ALLOWIMGWhether to allow users to upload images (true/false).false
USER_ALLOWCHECKWhether to enable a check feature for users (true/false).false
USER_SOURCEA user source setting (numeric).0
USER_MAXSOURCEA maximum user source setting (numeric).0
USER_TIMEOUTA timeout setting for users (numeric).0

⁠SMTP (Email) Configuration

These variables are for configuring an SMTP server to send emails.

VariableDescriptionDefault Value
SMTP_HOSTThe SMTP server hostname.(none)
SMTP_PROTOCOLThe protocol to use for SMTP (e.g., TLSv1.2).TLSv1.2
SMTP_PORTThe SMTP server port.(none)
SMTP_ACCOUNTThe username for the SMTP account.(none)
SMTP_PASSWORDThe password for the SMTP account.(none)
SMTP_PERSONALThe "From" name displayed in sent emails.(none)
SMTP_CODESUBJECTThe subject line for verification code emails.验证码 (Verification Code)
SMTP_CODETEXTThe body text for verification code emails.您的验证码是$code...

⁠General & Server Configuration

Miscellaneous application and server performance settings.

VariableDescriptionDefault Value
DEFAULT_TTSA default Text-to-Speech (TTS) setting.(none)
DEFAULT_RULEA default rule setting.(none)
SERVER_HTTP_CORETHREADSThe number of core threads for the HTTP server.x5
SERVER_HTTP_MAXTHREADSThe maximum number of threads for the HTTP server.x10

⁠Proxy Configuration

These variables configure the Java runtime to use an HTTP/S proxy and are used directly in the java command.

VariableDescriptionDefault Value
PROXY_HOSTThe hostname or IP of the proxy server.(none)
PROXY_PORTThe port of the proxy server.(none)

⁠Example

⁠Run with MySQL and Redis

docker-compose.yaml

version: '3.8'

services:
  # The Read application service
  app:
    image: mountaincnc/read:2.18.1
    restart: unless-stopped
    ports:
      - "127.0.0.1:18888:8080"
    # Set the environment variables needed by the entrypoint script
    environment:
      # --- Set up timezone ---
      - TZ=Asia/Shanghai
      # --- Database Configuration ---
      - DB_TYPE=mysql
      - DB_HOST=db
      - DB_PORT=3306
      - DB_DATABASE=read_db
      - DB_USERNAME=read_user
      - DB_PASSWORD=read_password
      # --- Cache Configuration ---
      - CACHE_DRIVERTYPE=redis
      - CACHE_SERVER=redis:6379
      # --- Admin User Configuration ---
      - ADMIN_USERNAME=admin
      - ADMIN_PASSWORD=chang_admin_password
      - ADMIN_CODE=invite_code
    # IMPORTANT: The mounted external configure file take precedence over environment variables!!!
    #volumes:
    #  - ./config.yaml:/app/conf.yml
    # This ensures that the database and cache are started before the app starts
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_started
    # Connect this service to our custom network
    networks:
      - read-network

  # The MySQL database service
  db:
    # Use an official MySQL image
    image: mysql:8.0
    restart: unless-stopped
    # Environment variables to initialize the MySQL database
    environment:
      # --- Set up timezone ---
      - TZ=Asia/Shanghai
      # This sets the root password for the MySQL server
      - MYSQL_ROOT_PASSWORD=very_strong_root_password
      # This creates the database for the application
      - MYSQL_DATABASE=read_db
      # This creates a dedicated user for the application
      - MYSQL_USER=read_user
      # This sets the password for the dedicated user
      - MYSQL_PASSWORD=read_password
    # Use a named volume to persist the database data
    volumes:
      - mysql-data:/var/lib/mysql
    # Healthcheck to ensure the database is ready for connections before dependent services start
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-pvery_strong_root_password"]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - read-network

  # The Redis cache service
  redis:
    # Use a lightweight official Redis image
    image: redis:7-alpine
    restart: unless-stopped
    environment:
      # --- Set up timezone ---
      - TZ=Asia/Shanghai
    # Use a named volume to persist Redis data (optional but good practice)
    volumes:
      - redis-data:/data
    networks:
      - read-network

# Top-level declaration for named volumes
volumes:
  mysql-data:
  redis-data:

# Top-level declaration for the custom network
networks:
  read-network:
    driver: bridge
⁠Run with SQLite

docker-compose.yaml

version: '3.8'

services:
  # The Read application service
  app:
    image: mountaincnc/read:2.18.1
    restart: unless-stopped
    ports:
      - "127.0.0.1:18888:8080"
    # Set the environment variables needed by the entrypoint script
    environment:
      # --- Set up timezone ---
      - TZ=Asia/Shanghai
      # --- Admin User Configuration ---
      - ADMIN_USERNAME=admin
      - ADMIN_PASSWORD=chang_admin_password
    volumes:
      - sqlite-data:/app/data
    # Connect this service to our custom network
    networks:
      - read-network

volumes:
  sqlite-data:

# Top-level declaration for the custom network
networks:
  read-network:
    driver: bridge

⁠Reverse Proxy

⁠Caddy(Recommand)
YOUR_DOMAIN {
        reverse_proxy 127.0.0.1:18888
}
⁠Nginx
server {
    listen [::]:80;
    server_name your.example.com example.com;

    location / {
        # Replace with the port your application is running on
        proxy_pass http://127.0.0.1:18888;

        # Standard proxy headers
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        # WebSocket specific headers
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

Tag summary

Content type

Image

Digest

sha256:75811e182…

Size

349.8 MB

Last updated

6 months ago

docker pull mountaincnc/read