TITLE: Initializing CKB Explorer Server Project (Shell) DESCRIPTION: This snippet outlines the initial setup steps for the CKB Explorer Server project. It involves navigating into the project directory, copying the example environment file, creating a local environment override file, and running the setup script to configure the application. SOURCE: https://github.com/nervosnetwork/ckb-explorer/blob/develop/README.md#_snippet_0 LANGUAGE: shell CODE: ``` $ cd ckb-explorer/ $ cp .env.example .env # (in this config file, please modify the items according to your local environment) $ touch .env.local # (overwrite `.env` config if you need in `.env.local`, such as DATABASE_URL,CKB_NODE_URL...) $ bin/setup ``` ---------------------------------------- TITLE: Running CKB Explorer Server and Sync Process (Shell/Ruby) DESCRIPTION: This snippet shows how to start the CKB Explorer Server and its associated block synchronization process. The first command starts the Rails web server, and the second command initiates the background process responsible for syncing data from the CKB chain. SOURCE: https://github.com/nervosnetwork/ckb-explorer/blob/develop/README.md#_snippet_3 LANGUAGE: shell CODE: ``` $ bundle exec rails s # start sync process $ ruby lib/ckb_block_node_processor.rb ``` ---------------------------------------- TITLE: Creating and Migrating PostgreSQL Database (Shell) DESCRIPTION: This snippet provides commands to set up the PostgreSQL database for the CKB Explorer Server. It includes creating development and test databases, and then loading the schema for both environments to apply migrations. SOURCE: https://github.com/nervosnetwork/ckb-explorer/blob/develop/README.md#_snippet_1 LANGUAGE: shell CODE: ``` bundle exec rake db:create # (create db for development and test) bundle exec rake db:schema:load # (run migration for development db) bundle exec rake db:schema:load RAILS_ENV=test # (run migration for test db) ``` ---------------------------------------- TITLE: Starting Docker Compose Services in Detached Mode (Shell) DESCRIPTION: This command starts all services defined in the Docker Compose configuration in detached mode, allowing them to run in the background. The CKB Explorer Service is composed of web, worker, blocksyncer, and scheduler processes. SOURCE: https://github.com/nervosnetwork/ckb-explorer/blob/develop/README.md#_snippet_5 LANGUAGE: shell CODE: ``` $ docker compose up -d ``` ---------------------------------------- TITLE: Building Docker Compose Image (Shell) DESCRIPTION: This command builds the Docker images defined in the `docker-compose.yml` file for the CKB Explorer Service. It prepares the necessary containers for deployment. SOURCE: https://github.com/nervosnetwork/ckb-explorer/blob/develop/README.md#_snippet_4 LANGUAGE: shell CODE: ``` $ docker compose build . ``` ---------------------------------------- TITLE: Running Rails Tests (Shell) DESCRIPTION: This command executes the test suite for the CKB Explorer Server, ensuring that all components are functioning as expected. It uses the `bundle exec rails test` command to run all defined tests. SOURCE: https://github.com/nervosnetwork/ckb-explorer/blob/develop/README.md#_snippet_2 LANGUAGE: shell CODE: ``` $ bundle exec rails test ```