Skip to content
This repository has been archived by the owner on Feb 19, 2024. It is now read-only.

Commit

Permalink
添加 arm64 docker 镜像
Browse files Browse the repository at this point in the history
  • Loading branch information
haiibo committed Aug 28, 2022
1 parent caacaac commit 19f586b
Show file tree
Hide file tree
Showing 9 changed files with 243 additions and 1 deletion.
69 changes: 69 additions & 0 deletions .github/workflows/ARMv8-Docker-BuildX.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: ARMv8 Docker BuildX

on:
workflow_dispatch:
schedule:
- cron: '30 16 * * 5'

env:
REPO_URL: https://github.com/coolsnowwolf/lede
REPO_BRANCH: master
DOCKER_BUILD: buildImageX.sh
DOCKER_IMAGE: summary/openwrt-aarch64
TZ: Asia/Shanghai

jobs:
build:
runs-on: ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@main

- name: Initialization environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc
sudo -E apt-get -qq update
sudo -E apt-get -qq install $(curl -fsSL is.gd/depends_ubuntu_2204)
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p /workdir
sudo chown $USER:$GROUPS /workdir
- name: Get openwrt version date
working-directory: /workdir
run: |
df -hT $PWD
git clone $REPO_URL -b $REPO_BRANCH openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
cd openwrt
version=$(echo "$(cat package/lean/default-settings/files/zzz-default-settings)" | grep -Po "DISTRIB_REVISION=\'\K[^\']*")
echo "TAG=$version" >> $GITHUB_ENV
- name: Check docker environment
run: |
echo "docker buildx version"
docker buildx version
echo "ls -l /proc/sys/fs/binfmt_misc"
ls -l /proc/sys/fs/binfmt_misc
echo "docker run --privileged --rm tonistiigi/binfmt --install all"
docker run --privileged --rm tonistiigi/binfmt --install all
echo "ls -l /proc/sys/fs/binfmt_misc"
ls -l /proc/sys/fs/binfmt_misc
echo "docker buildx ls"
docker buildx ls
- name: Build and push docker image
run: |
cd $GITHUB_WORKSPACE/docker
wget -q https://github.com/${GITHUB_REPOSITORY}/releases/download/ROOTFS_PLUS/openwrt-armvirt-64-default-rootfs.tar.gz
chmod +x $DOCKER_BUILD
./$DOCKER_BUILD
gzip -dc dockerimgs/docker/*.gz | docker load
docker login --username=${{ secrets.DOCKER_USERNAME }} --password=${{ secrets.DOCKER_PASSWORD }}
docker tag ${{ env.DOCKER_IMAGE }} ${{ env.DOCKER_IMAGE }}:${{ env.TAG }}
docker push ${{ env.DOCKER_IMAGE }}:${{ env.TAG }}
docker push ${{ env.DOCKER_IMAGE }}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
- 适配的软路由设备:`X86_64``NanoPi R2C``NanoPi R2S``NanoPi R4S``NanoPi R5S``树莓派 4B``R68S`
- 适配的 ARM 盒子设备:`微加云``贝壳云``我家云``斐讯N1``章鱼星球``S905x2``S905x3`(包括常见的 HK1、H96、X96 等盒子)、`S922x`(目前支持 GT-King、GT-King Pro、Odroid N2 三款盒子)
- ARM 盒子固件分为 [Mini版](https://github.com/haiibo/OpenWrt/releases/tag/ARMv8_MINI)[Plus版](https://github.com/haiibo/OpenWrt/releases/tag/ARMv8_PLUS),Mini 精简版以科学上网为主,Plus 多功能版插件多适合折腾
- ARM64 Docker 镜像使用 PLUS 版为底包,镜像拉取命令:`docker pull summary/openwrt-aarch64:latest`
- 固件集成的所有 ipk 插件全部打包在 Packages 文件中,可以在 [Releases](https://github.com/haiibo/OpenWrt/releases) 内进行下载
- 仓库编译的固件插件均为最新版本,最新版可能有 BUG,如果之前使用稳定,则无需追新
- 项目编译的固件插件为最新版本,最新版插件可能有 BUG,如果之前使用稳定,则无需追新
- 喜欢的可以给个 Star,感谢各位!想要自己编译固件的请看下方定制固件!


Expand Down
5 changes: 5 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM scratch
ADD openwrt-armvirt-64-default-rootfs-patched.tar /
EXPOSE 22 53 80 443 7681
# using exec format so that /sbin/init is proc 1 (see procd docs)
ENTRYPOINT ["/sbin/init"]
35 changes: 35 additions & 0 deletions docker/buildImageX.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

TAG=latest
if [ ! -z "$1" ];then
TAG=$1
fi

TMPDIR=openwrt_rootfs
OUTDIR=dockerimgs/docker
IMG_NAME=summary/openwrt-aarch64

[ -d "$TMPDIR" ] && rm -rf "$TMPDIR"

mkdir -p "$TMPDIR" && \
mkdir -p "$OUTDIR" && \
gzip -dc openwrt-armvirt-64-default-rootfs.tar.gz | ( cd "$TMPDIR" && tar xf - ) && \
cp -f patches/rc.local "$TMPDIR/etc/" && \
cp -f patches/cpustat "$TMPDIR/usr/bin/" && chmod 755 "$TMPDIR/usr/bin/cpustat" && \
cp -f patches/getcpu "$TMPDIR/bin/" && chmod 755 "$TMPDIR/bin/getcpu" && \
cat patches/luci-admin-status-index-html.patch | (cd "$TMPDIR/usr/lib/lua/luci/view/admin_status/" && patch -p0) && \
rm -f "$TMPDIR/etc/bench.log" && \
sed -e 's/\/opt/\/etc/' -i "${TMPDIR}/etc/config/qbittorrent" && \
# sed -e "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/" -i "${TMPDIR}/etc/ssh/sshd_config" && \
sss=$(date +%s) && \
ddd=$((sss/86400)) && \
sed -e "s/:0:0:99999:7:::/:${ddd}:0:99999:7:::/" -i "${TMPDIR}/etc/shadow" && \
echo "17 3 * * * /etc/coremark.sh" >> "$TMPDIR/etc/crontabs/root" && \
rm -rf "$TMPDIR/lib/firmware/*" "$TMPDIR/lib/modules/*" && \
(cd "$TMPDIR" && tar cf ../openwrt-armvirt-64-default-rootfs-patched.tar .) && \
rm -f DockerImg-OpenwrtArm64-${TAG}.gz && \
# docker build -t ${IMG_NAME}:${TAG} . && \
docker buildx build --platform=linux/arm64 -o type=docker -t ${IMG_NAME}:${TAG} . && \
rm -f openwrt-armvirt-64-default-rootfs-patched.tar && \
rm -rf "$TMPDIR" && \
docker save ${IMG_NAME}:${TAG} | pigz -9 > $OUTDIR/docker-img-openwrt-aarch64-${TAG}.gz
41 changes: 41 additions & 0 deletions docker/patches/cpustat
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env perl
#use strict;
use utf8;
binmode(STDOUT, ":utf8");

sub get_soc_temp {
my @fnames=(
'/sys/devices/virtual/thermal/thermal_zone0/temp',
'/sys/devices/platform/scpi/scpi:sensors/hwmon/hwmon0/temp1_input',
);
my $fh;
my $temp = "Unknown";
for my $fname (@fnames) {
if( -f $fname ) {
open $fh, "<", $fname;
$temp = sprintf "%0.1f℃", <$fh> / 1000;
close $fh;
return $temp;
}
}
return $temp;
}

sub get_cpu_freq {
my @fnames=(
'/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq',
);
my $fh;
my $freq = "Unknown";
for my $fname (@fnames) {
if( -f $fname ) {
open $fh, "<", $fname;
$freq = sprintf "%dMhz", <$fh> / 1000;
close $fh;
return $freq;
}
}
return $freq;
}

print &get_cpu_freq, " / ", &get_soc_temp, "\n";
Binary file added docker/patches/dnsmasq
Binary file not shown.
30 changes: 30 additions & 0 deletions docker/patches/getcpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env perl
#use strict;

sub get_stat {
open IN, "<", "/proc/stat";
$_ = <IN>;
chomp;
close(IN);
my ($cpu, $user, $nice, $system, $idle, $iowait, $irq, $softirq, $steal, $guest, $guest_nice) = split;
my $Idle = $idle + $iowait;
my $Non_Idle = $user + $nice + $system + $irq + $softirq + $steal + $guest + $guest_nice;
return ($Idle, $Non_Idle);
}

my($prev_idle, $prev_non_idle) = &get_stat;
my $prev_total = $prev_idle + $prev_non_idle;
sleep(3);
my($idle, $non_idle) = &get_stat;
my $total = $idle + $non_idle;

my $totald = $total - $prev_total;
my $idled = $idle - $prev_idle;
my $cpu_percentage = ($totald - $idled) / $totald * 100;

$| = 1;
open OUT, ">", "/tmp/cpuusage";
printf OUT "%0.1f\%", $cpu_percentage;
close(OUT);

exit(0);
48 changes: 48 additions & 0 deletions docker/patches/luci-admin-status-index-html.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
--- index.htm.orig 2020-03-12 22:49:17.000000000 +0800
+++ index.htm 2020-03-13 00:49:19.000000000 +0800
@@ -17,6 +17,7 @@
local sysinfo = luci.util.ubus("system", "info") or { }
local boardinfo = luci.util.ubus("system", "board") or { }
local unameinfo = nixio.uname() or { }
+ local cpustat = luci.sys.exec("/usr/bin/cpustat") or { }

local meminfo = sysinfo.memory or {
total = 0,
@@ -43,8 +44,7 @@
fs.readfile("/proc/sys/net/netfilter/nf_conntrack_count") or "") or 0

local conn_max = tonumber(luci.sys.exec(
- "sysctl -n -e net.nf_conntrack_max net.ipv4.netfilter.ip_conntrack_max"
- ):match("%d+")) or 4096
+ "sysctl -n -e net.netfilter.nf_conntrack_max net.nf_conntrack_max net.ipv4.netfilter.ip_conntrack_max | head -n 1"):match("%d+")) or 4096

local user_info = tonumber(luci.sys.exec("cat /proc/net/arp | grep 'br-lan' | grep '0x2' | wc -l"))

@@ -65,7 +65,8 @@
conncount = conn_count,
leases = stat.dhcp_leases(),
leases6 = stat.dhcp6_leases(),
- wifinets = stat.wifi_networks()
+ wifinets = stat.wifi_networks(),
+ cpustat = luci.sys.exec("/usr/bin/cpustat") or { }
}

if wan then
@@ -637,6 +638,9 @@
if (e = document.getElementById('localtime'))
e.innerHTML = info.localtime;

+ if (e = document.getElementById('cpustat'))
+ e.innerHTML = info.cpustat;
+
if (e = document.getElementById('uptime'))
e.innerHTML = String.format('%t', info.uptime);

@@ -701,6 +705,7 @@
<tr><td width="33%"><%:Kernel Version%></td><td><%=unameinfo.release or "?"%></td></tr>
<tr><td width="33%"><%:Local Time%></td><td id="localtime">-</td></tr>
<tr><td width="33%"><%:Uptime%></td><td id="uptime">-</td></tr>
+ <tr><td width="33%"><%:CPU状态%></td><td id="cpustat">-</td></tr>
<tr><td width="33%"><%:Load Average%></td><td id="loadavg">-</td></tr>
<tr><td width="33%"><%:CPU usage (%)%></td><td id="cpuusage">-</td></tr>
</table>
13 changes: 13 additions & 0 deletions docker/patches/rc.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 修复在某些docker环境下网络卡顿的问题, 如果非必要请勿删除!
cat > /etc/resolv.conf <<EOF
search lan
nameserver 127.0.0.1
options ndots:0
EOF

#
#
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

exit 0

0 comments on commit 19f586b

Please sign in to comment.