FaynoSync

repository·main·Indexed 41 days ago

https://github.com/ku9nov/faynosync

A self-hosted, open-source API server for managing and distributing updates for cross-platform desktop applications on Windows, macOS, and Linux. It provides a REST API for version checks and supports hosting builds on S3-compatible storage, featuring integration with MongoDB, Redis, and TUF (The Update Framework).

Tokens
5.8K
Snippets
26
Records
33
Agent score
100%

What's inside FaynoSync

  1. Monitor faynoSync Cache Status via X-Cache-Status

    main

    The optimized /checkVersion location uses microcaching. You can monitor the effectiveness of the cache by inspecting the X-Cache-Status header in the HTTP response.

    Possible values:

    • HIT: Request served from cache.
    • MISS: Request fetched from the backend.
    • UPDATING: Cache is being updated in the background.
    • STALE: Served stale content due to backend issues.
  2. Quickstart with Docker Compose

    main

    To spin up a complete FaynoSync environment including the API, MongoDB, Redis, Garage (S3-compatible storage), and the Dashboard, use Docker Compose. After the stack is healthy, you must run the database migrations.

    1. Clone the repository and enter the directory.
    2. Run docker compose up --build.
    3. Run the migration command via Docker exec.

    The API will be available at http://localhost:9000 and the Dashboard at http://localhost:3000.

    git clone https://github.com/ku9nov/faynoSync.git
    cd faynoSync
    docker compose up --build
    docker compose exec -T backend /usr/bin/faynoSync migrate up
  3. Recommended local storage setup with Garage

    main

    For local development, use Garage with the aws storage driver. This setup is compatible with the provided Docker Compose stack. Note that MinIO is deprecated and should not be used for new local deployments.

    STORAGE_DRIVER=aws
    MINIO_SECURE=false
    S3_ACCESS_KEY=GK8fcbbed327a9ff97f250eb4e
    S3_SECRET_KEY=8a59fe92499699d139fcee6998343dad2ac73fb2b5dffafa0a7d0b0d4e305db9
    S3_BUCKET_NAME_PRIVATE=cb-faynosync-s3-private
    S3_BUCKET_NAME=cb-faynosync-s3-public
    S3_BUCKET_NAME_CDN=cb-faynosync-s3-public
    S3_ENDPOINT_PRIVATE=http://cb-faynosync-s3-private.web.garage.localhost:3902
    S3_ENDPOINT=http://cb-faynosync-s3-public.web.garage.localhost:3902
    S3_API_ENDPOINT=http://127.0.0.1:3900
    S3_FORCE_PATH_STYLE=true
    S3_DISABLE_OBJECT_ACL=true
    S3_REGION=garage
  4. Build and run FaynoSync from source

    main

    To run the auto-updater service manually from source:

    1. Build the binary:
    go build -o faynoSync faynoSync.go
    1. Start the API server:
    ./faynoSync
    1. Run migrations (after the API passes health checks):
    ./faynoSync migrate up
    1. Rollback migrations if necessary:
    ./faynoSync migrate down
    go build -o faynoSync faynoSync.go
    ./faynoSync
    ./faynoSync migrate up
  5. Adapt a TUF client for faynoSync

    main

    When using a go-tuf client implementation with faynoSync, you must adapt the configuration to match faynoSync's metadata and target storage layout. Specifically, ensure the following settings are applied:

    1. metadataURL: Point this to your faynoSync metadata storage location.
    2. targetsURL: Point this to your faynoSync target storage location.
    3. targetName: Set this to the specific faynoSync target path you wish to verify.
    4. cfg.PrefixTargetsWithHash: Set this to false. This is required to match the faynoSync target URL layout, which does not use hash-prefixed target paths.
  6. Set up FaynoSync for local development

    main

    If you want to run the API and dashboard from your local source code while keeping dependency services (MongoDB, Redis, and Garage) containerized, use the development override file. This scales the backend and frontend services to 0 replicas in Docker, allowing you to run them manually.

    docker compose -f docker-compose.yaml -f docker-compose.development.yaml up
  7. Run FaynoSync with Docker Compose

    main

    To build and run the full FaynoSync API stack including all dependencies, use the standard Docker Compose command. This will orchestrate the backend and required services.

    docker compose up --build
  8. Quick Setup for faynoSync Nginx Reverse Proxy

    main

    To deploy faynoSync behind an Nginx reverse proxy, follow these steps to install and enable the provided configuration file:

    1. Copy the configuration to your Nginx sites directory:
      sudo cp faynosync.conf /etc/nginx/sites-available/faynosync.conf
    2. Enable the site by creating a symbolic link:
      sudo ln -s /etc/nginx/sites-available/faynosync.conf /etc/nginx/sites-enabled/
    3. Test the Nginx configuration for syntax errors:
      sudo nginx -t
    4. Reload Nginx to apply changes:
      sudo systemctl reload nginx
    sudo cp faynosync.conf /etc/nginx/sites-available/faynosync.conf
    sudo ln -s /etc/nginx/sites-available/faynosync.conf /etc/nginx/sites-enabled/
    sudo nginx -t
    sudo systemctl reload nginx
  9. Run migrations in Docker

    main

    After the Docker Compose environment is up, you must run migrations to prepare the database. Execute the migrate up command within the backend container.

    docker compose exec -T backend /usr/bin/faynoSync migrate up
  10. Run FaynoSync tests

    main

    FaynoSync supports several testing modes:

    • End-to-End Tests: Run using the standard Go test command.
    • Test Binary: Build a specific test binary using go test -c.
    • Unit Tests (TUF functionality): Run specific tests for the TUF implementation. You may need to set MONGODB_URL_TESTS if these tests require a live MongoDB connection.

    Note: To run tests successfully, ensure your .env file is populated, as tests verify the API using a test database and an existing S3 bucket.

    # End-to-End
    go test
    
    # Build test binary
    go test -c -o faynoSync_tests
    
    # Unit tests for TUF
    go test ./server/tuf/...
  11. Manage database migrations

    main

    FaynoSync uses the golang-migrate tool for database schema management.

    1. Create a migration: Navigate to mongod/migrations and use the migrate create command.
    2. Apply migrations: Use the built-in FaynoSync command to run migrations up or down.
    # Create new migration
    cd mongod/migrations
    migrate create -ext json name_of_migration
    
    # Apply migrations
    ./faynoSync migrate up