SMSGate Server

repository·master·Indexed 41 days ago

https://github.com/android-sms-gateway/server

A REST API backend that dispatches SMS messages through connected Android devices via Firebase Cloud Messaging (FCM). It supports public and private deployment modes, provides a comprehensive API for message and device management, and can be deployed via Docker, Docker Compose, or Helm charts on Kubernetes.

Tokens
8.1K
Snippets
38
Records
43
Agent score
51%

What's inside SMSGate

  1. Quickstart SMSGate Server deployment

    master

    You can deploy the SMSGate Server using Docker, Docker Compose, or by building from source.

    Docker Run

    To run the server as a single container, map port 3000 and mount your configuration file:

    Docker Compose

    For a full stack deployment including the backend, worker, and MariaDB, use the provided Compose file:

    Local Development

    If you are developing locally with Go, use the following Makefile commands:

    • make run: Starts the server via go run ./cmd/sms-gateway/main.go.
    • make air: Starts the server with hot-reloading (sets TZ=UTC and DEBUG=1).
    • make db-upgrade: Applies database migrations.
    # Docker Run
    docker run -p 3000:3000 \
      -v ./configs/config.yml:/app/config.yml \
      ghcr.io/android-sms-gateway/server:latest
    
    # Docker Compose
    docker compose -f deployments/docker-compose/docker-compose.yml up --build
    
    # Local Development
    make run
    make air
    make db-upgrade
  2. Prerequisites for Docker Compose Deployment

    master

    Before deploying SMSGate using the Docker Compose single-file method, ensure your environment meets these requirements:

    • Docker Compose: version 2.23.1 or later.
    • Portainer (optional): version 2.20.0 or later if using it for management.
    • Network: Your server must have a public IP address.
    • DNS: A domain name must be configured to point to your server's public IP address.
  3. Configure environment variables for deployment

    master

    Create a .env file in the root directory of your project to define essential credentials and network settings. Replace all [placeholder] values with your actual sensitive data.

    MYSQL_ROOT_PASSWORD=[your_root_password]
    MYSQL_PASSWORD=[your_mysql_password]
    DOMAIN=sms.example.com
    ACME_EMAIL=email@example.com
    GATEWAY_PRIVATE_TOKEN=[your_private_token]
  4. Configure SMSGate Server via YAML or Environment Variables

    master

    Configuration is primarily managed through a YAML file (e.g., configs/config.yml). Every configuration key can be overridden using environment variables following the pattern SECTION__KEY (using double underscores).

    Key Sections:

    • database
    • gateway
    • http
    • fcm
    • sse
    • messages
    • cache
    • pubsub
    • jwt
    • otp
    • tasks

    To run in private mode, you must set gateway.mode: private and provide a gateway.private_token in your configuration.

    export GATEWAY__MODE=private
    export GATEWAY__PRIVATE_TOKEN=change-me
    export DATABASE__HOST=localhost
    export HTTP__LISTEN=0.0.0.0:3000
  5. Understand the SMSGate Docker Compose architecture

    master

    The sms-gateway-proxy deployment consists of four main components working together:

    1. reproxy: A reverse proxy service (umputun/reproxy) that handles incoming traffic on ports 80 and 443. It manages SSL certificates automatically via ACME and routes traffic to the backend.
    2. backend: The primary SMSGate server service (ghcr.io/android-sms-gateway/server:latest) that handles HTTP requests.
    3. worker: A secondary instance of the server service running in worker mode (/app/app worker). This is used for background processing tasks.
    4. db: A MariaDB container (mariadb:lts) providing persistent storage for the application data.

    Service Dependencies:

    • The backend and worker services depend on the db service being healthy before they start.
    • The backend and worker services share the same config.yml configuration provided via Docker configs.
  6. Mount configuration files to the gateway

    master

    You can provide configuration to the gateway in two ways by setting gateway.config.enabled: true:

    1. Using an existing ConfigMap: Reference a pre-existing Kubernetes ConfigMap via gateway.config.existingConfigMap.
    2. Using inline YAML: Provide the configuration content directly via gateway.config.data.
    ### Using an Existing ConfigMap
    ```yaml
    gateway:
      config:
        enabled: true
        existingConfigMap: my-existing-configmap

    Using Inline YAML Configuration

    gateway:
      config:
        enabled: true
        data: |
          tasks:
            hashing:
              interval_seconds: 900