AdguardTeam / AdGuardHome

Network-wide ads & trackers blocking DNS server
https://adguard.com/adguard-home/overview.html
GNU General Public License v3.0
25.67k stars 1.84k forks source link

Automated install script & docker build for riscv64 #7443

Open ngc7331 opened 1 week ago

ngc7331 commented 1 week ago

Prerequisites

The problem

I tried to run curl -s -S -L https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s -- -v on a riscv64 machine but the script complained unsupported cpu type: riscv64.

As far as I see, riscv64 is supported in #5704. I was indeed able to manually install it and everything works fine.

Proposed solution

Please consider adding riscv64 to the automated install script: https://github.com/AdguardTeam/AdGuardHome/blob/1d6d85cff4bf5915156f28d07582b4f0bb359d04/scripts/install.sh#L227

Alternatives considered and additional information

No response

ngc7331 commented 1 day ago

Also, we should able to support docker on riscv64 by simply using alpine:3.20 as the base image. https://github.com/AdguardTeam/AdGuardHome/blob/abb738013a3d0648e71793991334c858ce75428e/docker/Dockerfile#L3

I was able to build image using the following command:

$ sed -i 's/alpine:3\.18/alpine:3.20/' docker/Dockerfile
$ mkdir -p dist dist/docker
$ wget https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.107.54/AdGuardHome_linux_riscv64.tar.gz
$ tar -xvf AdGuardHome_linux_riscv64.tar.gz
./AdGuardHome/
./AdGuardHome/AdGuardHome
./AdGuardHome/LICENSE.txt
./AdGuardHome/AdGuardHome.sig
./AdGuardHome/README.md
./AdGuardHome/CHANGELOG.md

$ cp AdGuardHome/AdGuardHome ./dist/docker/AdGuardHome_linux_riscv64_
$ docker buildx build -f docker/Dockerfile -t ngc7331/adguardhome:latest --build-arg DIST_DIR=dist --platform linux/riscv64 --push .
[+] Building 6.2s (11/11) FINISHED                                                                                                                                                                   remote:local
 => [internal] load build definition from Dockerfile                                                                                                                                                         0.0s
 => => transferring dockerfile: 2.04kB                                                                                                                                                                       0.0s
 => [internal] load metadata for docker.io/library/alpine:3.20                                                                                                                                               1.1s
 => [internal] load .dockerignore                                                                                                                                                                            0.0s
 => => transferring context: 112B                                                                                                                                                                            0.0s
 => [1/5] FROM docker.io/library/alpine:3.20@sha256:1e42bbe2508154c9126d48c2b8a75420c3544343bf86fd041fb7527e017a4b4a
(log redacted)

Image: https://hub.docker.com/r/ngc7331/adguardhome/tags

Then I was able to run AGH on a Milk-V Duo-S board and everything works fine:

$ fastfetch
       _,met$$$$$gg.           root@DuoS
    ,g$$$$$$$$$$$$$$$P.        ------------
  ,g$$P"         """Y$$.".     OS: Debian GNU/Linux trixie trixie/sid riscv64
 ,$$P'               `$$$.     Host: Milk-V DuoS
',$$P       ,ggs.     `$$b:    Kernel: Linux 5.10.4-20241113-2-xu.1+
`d$$'     ,$P"'   .    $$$     Uptime: 1 hour, 38 mins
 $$P      d$'     ,    $$$P    Packages: 412 (dpkg)
 $$:      $.   -    ,d$$'      Shell: bash 5.2.32
 $$;      Y$b._   _,d$P'       Terminal: /dev/pts/1
 Y$$.    `.`"Y$$$$P"'          CPU: rv64gvcsu
 `$$b      "-.__               Memory: 299.25 MiB / 486.14 MiB (62%)
  `Y$$                         Swap: Disabled
   `Y$$.                       Disk (/): 5.43 GiB / 29.00 GiB (19%) - ext4
     `$$b.                     Local IP (end0): 192.168.24.10/24
       `Y$$b.                  Locale: C
          `"Y$b._
             `"""                                      

$ cat docker-compose.yaml
(irrelevant info redacted)
  adguard:
    container_name: adguard
    image: ngc7331/adguardhome:latest
    restart: unless-stopped
    networks:
      - default
    ports:
      - 53:53/tcp # DNS
      - 53:53/udp # DNS
      - 443:443/udp # DNS over HTTPS
      - 853:853/tcp # DNS over TLS
      - 853:853/udp # DNS over QUIC
    volumes:
      - adguard_config:/opt/adguardhome/conf:rw
      - adguard_data:/opt/adguardhome/work:rw

$ docker-compose up -d
Creating adguard ... done

$ docker logs adguard
2024/11/24 15:49:17.415116 [info] AdGuard Home, version v0.107.54
2024/11/24 15:49:17.702808 [info] tls: using default ciphers
2024/11/24 15:49:18.117518 [info] Initializing auth module: /opt/adguardhome/work/data/sessions.db
2024/11/24 15:49:18.151086 [info] auth: initialized.  users:1  sessions:1
2024/11/24 15:49:18.248908 [info] tls: number of certs: 2
2024/11/24 15:49:18.250423 [info] tls: got an intermediate cert
2024/11/24 15:49:22.127424 [info] AdGuard Home updates are disabled
2024/11/24 15:49:22.137826 [info] web: initializing
2024/11/24 15:49:24.483639 [info] dnsproxy: upstream mode is set mode=load_balance
2024/11/24 15:49:24.486151 [info] dnsproxy: cache enabled size=4096
2024/11/24 15:49:24.487459 [info] dnsproxy: max goroutines is set count=300
2024/11/24 15:49:24.495167 [info] dnsproxy: server will refuse requests of type any
2024/11/24 15:49:24.496541 [info] dnsproxy: upstream mode is set mode=load_balance
2024/11/24 15:49:24.498879 [info] dnsproxy: cache enabled size=4194304
2024/11/24 15:49:24.504903 [info] dnsproxy: max goroutines is set count=300
2024/11/24 15:49:24.516640 [info] addrproc: processing addresses
2024/11/24 15:49:24.519571 [info] permcheck: SECURITY WARNING: directory "/opt/adguardhome/work" has unexpected permissions 0755; want 0700
2024/11/24 15:49:24.524992 [info] AdGuard Home is available at the following addresses:
2024/11/24 15:49:24.528378 [info] go to http://127.0.0.1:3000
2024/11/24 15:49:24.536322 [info] go to http://[::1]:3000
2024/11/24 15:49:24.550677 [info] go to http://172.18.0.4:3000
2024/11/24 15:50:06.816170 [info] dnsproxy: starting dns proxy server
2024/11/24 15:50:06.819003 [info] dnsproxy: creating udp server socket addr=0.0.0.0:53
2024/11/24 15:50:06.831976 [info] dnsproxy: listening to udp addr=[::]:53
2024/11/24 15:50:06.833195 [info] dnsproxy: creating tcp server socket addr=0.0.0.0:53
2024/11/24 15:50:06.841390 [info] dnsproxy: listening to tcp addr=[::]:53
2024/11/24 15:50:06.842456 [info] dnsproxy: creating tls server socket addr=0.0.0.0:853
2024/11/24 15:50:06.847297 [info] dnsproxy: listening to tls addr=[::]:853
2024/11/24 15:50:06.849047 [info] dnsproxy: creating quic listener addr=0.0.0.0:853

And, maybe we should add riscv64 to build script for CI. https://github.com/AdguardTeam/AdGuardHome/blob/abb738013a3d0648e71793991334c858ce75428e/scripts/make/build-docker.sh#L33-L34 https://github.com/AdguardTeam/AdGuardHome/blob/abb738013a3d0648e71793991334c858ce75428e/scripts/make/build-docker.sh#L93-L95

Should I submit another issue for this?