メインコンテンツへスキップ

Developing Blocklet in Docker

When you are unable or unwilling to directly install @blocklet/cli on the computer for some reason, it can be difficult to develop Blocklet because @blocklet/cli is an essential tool for developing or running Blocklet

The following will introduce how to develop a blocklet on a computer without installing @blocklet/cli , but through Docker

  1. Install Docker

Please refer to the Docker Official tutorial, or other Docker installation tutorials to complete the installation

  1. Prepare the docker-compose.yaml file
javascript
services:
  blocklet-server:
    container_name: blocklet-server-docker
    image: arcblock/blocklet-server-dev
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./data:/data # Store blocklet-server data on ./data folder
      - ./code:/workspace/app # Store blocklet code on ./code folder
      - node_modules:/workspace/app/node_modules # Don't mount node_modules folder
      # - pnpm-store: /workspace/app/.pnpm-store # If you are using pnpm to install deps, you would better to add this config
    environment:
      ABT_NODE_HOST: 192.168.1.111 # Your host IP
  1. Start the container using docker compose up -d
  2. Enter the container using the docker compose exec --workdir=/workspace/app blocklet-server /bin/bash command
  3. Perform blocklet create ./, choose the template you want to create, and follow the prompts to complete the project creation
  4. Install dependencies npm i or yarn or pnpm i
  5. Execute blocklet dev
  6. The program will start up and print an accessible address
  7. Clicking on the address will let you access the current blocklet normally