This commit is contained in:
iCodex
2024-02-24 23:33:41 +08:00
commit 54755602e4
11 changed files with 348 additions and 0 deletions

17
docker/Dockerfile.admin Normal file
View File

@@ -0,0 +1,17 @@
FROM alpine:latest
LABEL maintainer="icodex@msn.com"
ENV TZ "Asia/Shanghai"
ENV ROOT_DIR /usr/local/goedge
ARG VERSION
ENV VERSION=${VERSION}
COPY build /build/
RUN /build/base.sh \
&& /build/install.sh admin
EXPOSE 7788 8001
WORKDIR /usr/local/goedge
ENTRYPOINT [ "/usr/local/goedge/run.sh" ]

17
docker/Dockerfile.node Normal file
View File

@@ -0,0 +1,17 @@
FROM alpine:latest
LABEL maintainer="icodex@msn.com"
ENV TZ "Asia/Shanghai"
ENV ROOT_DIR /usr/local/goedge
ARG VERSION
ENV VERSION=${VERSION}
COPY build /build/
RUN /build/base.sh \
&& /build/install.sh node
EXPOSE 80 443
WORKDIR /usr/local/goedge
ENTRYPOINT [ "/usr/local/goedge/run.sh" ]

17
docker/build.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/env bash
VERSION="1.3.3"
case "$1" in
"admin"|"node")
RUN_TYPE=${1}
;;
*)
echo "unknown type: ${1}"
exit
;;
esac
docker buildx create --use --platform=linux/arm64,linux/amd64 --name multi-platform-builder
docker buildx inspect --bootstrap
docker buildx build -f Dockerfile.${RUN_TYPE} -t icodex/edge-${RUN_TYPE}:${VERSION} --build-arg VERSION=${VERSION} --platform=linux/arm64,linux/amd64 . --push

5
docker/build/base.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/usr/bin/env sh
echo "**** Install based packages ****"
apk add --no-cache tzdata wget curl unzip
cp /usr/share/zoneinfo/${TZ} /etc/localtime

57
docker/build/install.sh Executable file
View File

@@ -0,0 +1,57 @@
#!/usr/bin/env sh
echo "**** Install goedge ****"
function get_arch() {
ARCH=`uname -m`
case "$ARCH" in
"x86_64")
GOARCH="amd64"
;;
"aarch64_be"|"aarch64"|"armv8b"|"armv8l"|"armv8"|"arm64")
GOARCH="arm64"
;;
*)
echo "arch '${ARCH}' is not supported yet"
exit
;;
esac
}
function install_edges() {
mkdir -p ${ROOT_DIR}
cd ${ROOT_DIR}
case "$1" in
"admin")
TAR_URL="https://dl.goedge.cn/edge/v${VERSION}/edge-admin-linux-${GOARCH}-plus-v${VERSION}.zip"
TAR_FILE="edge-admin-linux-${GOARCH}-plus-v${VERSION}.zip"
mv /build/run_admin.sh ${ROOT_DIR}/run.sh
;;
"node")
apk add --no-cache nftables
TAR_URL="https://dl.goedge.cn/edge-node/v${VERSION}/edge-node-linux-${GOARCH}-plus-v${VERSION}.zip"
TAR_FILE="edge-node-linux-${GOARCH}-plus-v${VERSION}.zip"
mv /build/run_node.sh ${ROOT_DIR}/run.sh
;;
*)
echo "unknown type: ${1}"
exit
;;
esac
chmod u+x ${ROOT_DIR}/run.sh
wget ${TAR_URL} -O ${TAR_FILE}
unzip ${TAR_FILE}
rm -f ${TAR_FILE}
}
function clean_apk() {
apk del wget curl unzip
}
get_arch
install_edges ${1}
clean_apk

4
docker/build/run_admin.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/usr/bin/env sh
ROOT_DIR='/usr/local/goedge'
${ROOT_DIR}/edge-admin/bin/edge-admin

20
docker/build/run_node.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env sh
ROOT_DIR='/usr/local/goedge'
function pre_config() {
if [ ! -e ${ROOT_DIR}/edge-node/configs/api_cluster.yaml ]; then
touch ${ROOT_DIR}/edge-node/configs/api_cluster.yaml
cat >> ${ROOT_DIR}/edge-node/configs/api_cluster.yaml << EOF
rpc.endpoints: [ "${ENDPOINTS}" ]
clusterId: "${CLUSTERID}"
secret: "${SECRET}"
EOF
fi
}
mkdir -p /opt/cache
chmod 777 /opt/cache
pre_config
${ROOT_DIR}/edge-node/bin/edge-node