Deploy Pickle-Finance Via Akash Decloud

174 阅读2分钟

Prepare docker image

  1. We clone the code from pickle-finance
git clone https://github.com/pickle-finance/pickle-ui.git
  1. Installation dependencies

    yarn 
    
  2. Run

    yarn start
    
  3. Visit http://localhost:3000/

  4. Packaged application

    yarn build
    

    the final generated file is in the .next directory

  5. Create Dockerfile

    vi Dockerfile
    

    fill in the following

    FROM nginx
    COPY .next /usr/share/nginx/html
    EXPOSE 80
    CMD ["nginx", "-g", "daemon off;"]
    
  6. Generate docker image

    docker build . -t sueinz/pickle-finance:latest
    

    output

    Sending build context to Docker daemon  261.2MB
    Step 1/4 : FROM nginx
     ---> bc9a0695f571
    Step 2/4 : COPY .next /usr/share/nginx/html
     ---> eb334c4e3d8d
    Step 3/4 : EXPOSE 80
     ---> Running in 176054dedab9
    Removing intermediate container 176054dedab9
     ---> 9f614780d0da
    Step 4/4 : CMD ["nginx", "-g", "daemon off;"]
     ---> Running in 7e78e7cf5668
    Removing intermediate container 7e78e7cf5668
     ---> 97471fe12c3d
    Successfully built 97471fe12c3d
    Successfully tagged sueinz/pickle-finance:latest
    
  7. View docker image

    docker images
    
  8. Run the container

    run in the background on port 3000

    docker run -d --name pickle-finance -p 3000:80 --restart=unless-stopped sueinz/pickle-finance:latest
    

    access via http://localhost:3000/

  9. Upload image

    docker push sueinz/pickle-finance:latest
    

Akash deployment environment preparation (Edgenet testnet)

Install wallet

The environment used here is ubuntu18.04

  1. Download akash wallet program

    wget https://github.com/ovrclk/akash/releases/download/v0.9.0-rc13/akash_0.9.0-rc13_linux_arm64.zip
    
  2. Unzip

    tar -xvf akash_0.9.0-rc13_linux_arm64.zip
    
  3. Rename directory

    mv akash_0.9.0-rc13_linux_arm64 akash
    
  4. Configure environment variables

    /work/akash/akash for the path we just unzipped

    edit /etc/profile , add the following at the end

    export PATH=$PATH:/work/akash/akash
    

    run after

    akash version
    

    output version number

    v0.9.0-rc13
    
  5. Create wallet address

    Here you need to prepare some variables in advance, KEY_NAME is a string set by yourself, the default is alice

    export KEY_NAME=alice
    export KEYRING_BACKEND=local
    

    enerate wallet address

    akash --keyring-backend "$KEYRING_BACKEND" keys add "$KEY_NAME"
    

    output

    - name: alice
      type: local
      address: akash1cz87pqkad72gggrv3t7y2x9z56h9gqghlnx3j3
      pubkey: akashpub1addwnpepqtnydvj056gy64uuquldq5yx7mr8ncmn3ut59wwl9p83d8h2v4rtg5xa3vn
      mnemonic: ""
      threshold: 0
      pubkeys: []
    
    
    **Important** write this mnemonic phrase in a safe place. It is the only way to recover your account if you ever forget your password.
    
    town wolf margin parrot strong disease dance eyebrow inflict meadow crunch version tube elite interest movie uphold column shift fox excuse humble nest call
    

    address is the account address we generated

    The last 24 words are very important. They are the mnemonic words of our wallet. We need to save them and restore them when importing them

Receive test coins

  1. Set a few commonly used variables first

    Set a few commonly used variables firstexport AKASH_NET="https://raw.githubusercontent.com/ovrclk/net/master/edgenet"
    export AKASH_CHAIN_ID="$(curl -s "$AKASH_NET/chain-id.txt")"
    exprot AKASH_NODE="$(curl -s "$AKASH_NET/rpc-nodes.txt" | shuf -n 1)"
    export ACCOUNT_ADDRESS=akash1cz87pqkad72gggrv3t7y2x9z56h9gqSet a few commonly used variables firstghlnx3j3
    

    AKASH_NET: the base URL of the network you want to connect to

    AKASH_CHAIN_ID: the ID of the chain to be connected

    AKASH_NODE: node RPC address

    ACCOUNT_ADDRESS: the wallet address generated earlier

  2. Run the command to view the faucet address for receiving test coins

    curl "$AKASH_NET/faucet-url.txt"
    

    output

    https://akash.vitwit.com/faucet
    
  3. Open this address in the browser and fill in the wallet address after passing the man-machine authentication. After waiting for a while, the account receives the test currency, and you can check the balance through the command

    akash --node "$AKASH_NODE" query bank balances "$ACCOUNT_ADDRESS"
    

    output

    balances:
    - amount: "100000000"
      denom: uakt
    pagination:
      next_key: null
      total: "0"
    

    The accuracy of akt is 6, so the balance should be 100000000 uakt = 100 akt

Deploy Pickle-Finance

  1. Configure the deploy.yml file according to the application deployment tutorial

    reate & edit deploy.yml file

    touch deploy.yml
    vi deploy.yml
    

    add the following

    ---
    version: "2.0"
    
    services:
      wordpress:
        image: sueinz/pickle-finance:latest 
        expose:
          - port: 80
            to:
              - global: true
    
    profiles:
      compute:
        wordpress:
          resources:
            cpu:
              units: 0.2
            memory:
              size: 512Mi
            storage:
              size: 512Mi
      placement:
        westcoast:
          signedBy:
            anyOf:
              - "akash1vz375dkt0c60annyp6mkzeejfq0qpyevhseu05"
          pricing:
            wordpress: 
              denom: uakt
              amount: 5000
    
    deployment:
      wordpress:
        westcoast:
          profile: web
          count: 1
    
    
  2. Deploy

    akash tx deployment create deploy.yml --from $KEY_NAME --node $AKASH_NODE --chain-id $AKASH_CHAIN_ID -y
    
  3. View the status of just deployed

    akash query market lease list --owner $ACCOUNT_ADDRESS --node $AKASH_NODE --state active
    

    output

    leases:
    - lease_id:
        dseq: "206109"
        gseq: 1
        oseq: 1
        owner: akash19uwxt0ln3p9fenpdwtsm5rlmqsekc3g9ym6xqz
        provider: akash15ql9ycjkkxhpc2nxtnf78qqjguwzz8gc4ue7wl
      price:
        amount: "249"
        denom: uakt
      state: active
    pagination:
      next_key: null
      total: "0"
    

    record several variables of the previous output for use

    export PROVIDER=akash15ql9ycjkkxhpc2nxtnf78qqjguwzz8gc4ue7wl
    export DSEQ=206109
    export OSEQ=1
    export GSEQ=1
    
  4. Upload Manifest

    akash provider send-manifest deploy.yml --node $AKASH_NODE --dseq $DSEQ --oseq $OSEQ --gseq $GSEQ --owner $ACCOUNT_ADDRESS --provider $PROVIDER
    
  5. View the specific information of the deployment

    akash provider lease-status --node $AKASH_NODE --dseq $DSEQ --oseq $OSEQ --gseq $GSEQ --provider $PROVIDER --owner $ACCOUNT_ADDRESS
    

    output

    {
      "services": {
        "web": {
          "name": "web",
          "available": 0,
          "total": 1,
          "uris": [
            "bat1ddainpepb77to5pqr661ss.provider4.akashdev.net"
          ],
          "observed-generation": 0,
          "replicas": 0,
          "updated-replicas": 0,
          "ready-replicas": 0,
          "available-replicas": 0
        }
      },
      "forwarded-ports": {}
    }
    
  6. Access the deployed application

    http://bat1ddainpepb77to5pqr661ss.provider4.akashdev.net/

  7. Close deployment

    akash tx deployment close --node $AKASH_NODE --chain-id $AKASH_CHAIN_ID --dseq $DSEQ --owner $ACCOUNT_ADDRESS --from $KEY_NAME -y
    

​ The deployment of the tutorial is now complete.