iCodex

iCodex

Deploy GoEdge quickly using Docker to build your own dedicated CDN service.

image

GoEdge is an open-source tool software for managing distributed CDN edge nodes, aiming to allow users to easily and cost-effectively create CDN/WAF and other applications. It is quite well-known in the industry and supports two platforms, x86 and arm64. It also has low system dependencies, making it a good choice for users to build their own CDN, in addition to purchasing commercial CDN services.

image

GoEdge is divided into a free community edition and a paid commercial edition. The commercial edition has some additional features, such as edge computing, HTTP/3, more detailed accessibility monitoring, 5-second shield, etc. You can learn more about the detailed differences here: GoEdge CDN Professional Edition, but to be honest, the community edition is already powerful enough.

For the installation of GoEdge, you can refer to the official tutorial. Here, I will introduce another method, which is to use Docker to quickly deploy the GoEdge management platform (including API nodes) and edge nodes. Let's get started!

Preparations before deployment#

Installing Docker#

Both the management platform and the edge nodes need to have Docker installed first. The latest version of Docker already includes the compose plugin, so we only need to execute the recommended command from the official website to install it:

curl -sSL https://get.docker.com | sh

Deploying the management platform#

First, write the docker-compose.yaml file. Since we are including the mysql that the management platform depends on, we will use docker compose for this purpose, which is also convenient for future migration and management work.

The recommended version for mysql is mysql 8, with a minimum requirement of mysql 5.7.8, and it is recommended to have at least 4GB of system memory.

First, go to the directory where you want to store the docker-compose.yaml file, such as /opt/goedge, then create the docker-compose.yaml file in that directory and enter the following content:

version: "3"

networks:
  goedge:
    external: false

services:
  mysqld:
    image: mysql:8
    container_name: mysqld
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_USER=edges
      - MYSQL_PASSWORD=edges
      - MYSQL_DATABASE=edges
    networks:
      - goedge
    volumes:
      - ./data/db/mysql:/var/lib/mysql:rw
    restart: always

  edge-admin:
    image: icodex/edge-admin:1.3.3
    container_name: edge-admin
    ports:
      - 7788:7788/tcp
      - 8001:8001/tcp
    networks:
      - goedge
    volumes:
      - ./data/edge-admin/configs:/usr/local/goedge/edge-admin/configs
      - ./data/edge-api/configs:/usr/local/goedge/edge-admin/edge-api/configs
    restart: always

The above code uses the mysql 8 image, and then edge-admin is the image for the management platform. After making sure there are no port conflicts, execute the following command to start:

docker compose up -d

After running the command, open a browser and enter the server's IP address and port 7788 to enter the installation interface:

image

Attention⚠️! Because the network type here is shared within the container, when filling in the database information, you only need to fill in the container name of mysql, such as mysqld. The database name, database account, and database password are all edges. Just click Next all the way.

ps: If you already have mysql in your host system and don't want to run another one to waste resources, you need to consider deleting the mysql service in the docker-compose.yaml file and changing the network type to Host network type, in order to facilitate communication with mysql on the host machine, as follows:

version: "3"

services:
  edge-admin:
    image: icodex/edge-admin:1.3.3
    container_name: edge-admin
    network_mode: host
    volumes:
      - ./data/edge-admin/configs:/usr/local/goedge/edge-admin/configs
      - ./data/edge-api/configs:/usr/local/goedge/edge-admin/edge-api/configs
    restart: always

After editing the docker-compose.yaml file, making sure there are no port conflicts, you can execute the following command to start the entire system!

Deploying the edge nodes#

In the deployment above, the deployment of the management platform has been completed. At this point, you can add edge nodes according to the official tutorial. Alternatively, you can follow the steps below to deploy an edge node in the form of a Docker container.

Here, we will use the automatic registration feature of GoEdge, so we need to go to the GoEdge management interface - Edge Nodes - Find your cluster - Cluster Nodes - Install/Upgrade - Automatic Registration, and record the values of endpoints, clusterId, and secret.

Then, prepare a docker-compose.yaml file and enter the following content, making sure to replace the corresponding values in the environment variables:

version: "3"

services:
  edge-node:
    image: icodex/edge-node:1.3.3
    container_name: edge-node
    environment:
      - ENDPOINTS=http://xxx.com:8001
      - CLUSTERID=xxx
      - SECRET=xxx
    network_mode: host
    cap_add:
      - NET_ADMIN
    volumes:
      - ./data/edge-node/cache:/opt/cache
      - ./data/edge-node/configs:/usr/local/goedge/edge-node/configs
    restart: always

Then use the docker compose command to start it, and soon you will be able to see this online host in the management platform.

That's it, the complete steps to deploy GoEdge, very simple!

Finally#

This project should not be considered reinventing the wheel, it's just my personal habit to use Docker for service management. After all, running Docker adds an extra layer of virtualization. Therefore, when choosing the network type for the containers of the edge nodes, it is recommended to use the host type, which is better for sharing with the host machine.

Finally, the files required for Docker image creation are stored on GitHub. You can click here to access: https://github.com/icodex/docker-goedge

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.