From 8c4b46fb70e52426f894496edfcc1e593b1d4613 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 18 Jan 2024 13:47:43 +0800 Subject: [PATCH] Add Yao Build Environment Docker Image --- .gitignore | 1 + Makefile | 7 +++--- docker/build/Dockerfile | 48 +++++++++++++++++++++++++++++++++++++++++ docker/build/build.sh | 16 ++++++++++++++ 4 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 docker/build/Dockerfile create mode 100644 docker/build/build.sh diff --git a/.gitignore b/.gitignore index b5bea6ba..3b4f8a2f 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,4 @@ xgen/v1.0/* !xgen/v1.0/umi.js !xgen/v1.0/layouts__index.async.js *-unit-test +docker/build/test \ No newline at end of file diff --git a/Makefile b/Makefile index b10a1c31..cb999979 100644 --- a/Makefile +++ b/Makefile @@ -176,15 +176,14 @@ artifacts-linux: clean # Making artifacts mkdir -p dist - CGO_ENABLED=1 CGO_LDFLAGS="-static" GOOS=linux GOARCH=amd64 go build -v -o dist/yao-${VERSION}-dev-linux-amd64 -# CGO_ENABLED=1 CGO_LDFLAGS="-static" GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ go build -v -o dist/yao-${VERSION}-dev-linux-arm64 - CGO_ENABLED=1 CGO_LDFLAGS="-static" LD_LIBRARY_PATH=/usr/lib/gcc-cross/aarch64-linux-gnu/13 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc-13 CXX=aarch64-linux-gnu-g++-13 go build -v -o dist/yao-${VERSION}-dev-linux-arm64 + CGO_ENABLED=1 CGO_LDFLAGS="-static" GOOS=linux GOARCH=amd64 go build -v -o dist/yao-${VERSION}-unstable-linux-amd64 + CGO_ENABLED=1 CGO_LDFLAGS="-static" LD_LIBRARY_PATH=/usr/lib/gcc-cross/aarch64-linux-gnu/13 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc-13 CXX=aarch64-linux-gnu-g++-13 go build -v -o dist/yao-${VERSION}-unstable-linux-arm64 mkdir -p dist/release mv dist/yao-*-* dist/release/ chmod +x dist/release/yao-*-* ls -l dist/release/ - dist/release/yao-${VERSION}-dev-linux-amd64 version + dist/release/yao-${VERSION}-unstable-linux-amd64 version # Reset const # cp -f share/const.goe share/const.go diff --git a/docker/build/Dockerfile b/docker/build/Dockerfile new file mode 100644 index 00000000..6d642b1a --- /dev/null +++ b/docker/build/Dockerfile @@ -0,0 +1,48 @@ +# =========================================== +# Yao Build Environment (Ubuntu 23.04 AMD64) +# +# Build: +# docker build --platform linux/amd64 -t yaoapp/yao-build:0.10.4 . +# +# Usage: +# docker run --rm -it -v /local/path/dist:/data yaoapp/yao-build:0.10.4 +# +# Tests: +# docker run --rm -it yaoapp/yao-build:0.10.4 /bin/bash +# docker run --rm -it -v ./test:/data yaoapp/yao-build:0.10.4 /bin/bash +# +# =========================================== +FROM ubuntu:23.04 +WORKDIR /app +ADD build.sh /app/build.sh +ENV PATH=$PATH:/usr/local/go/bin:/root/go/bin + +RUN apt-get update && \ + apt-get install -y libc6-armel-cross libc6-dev-armel-cross binutils-arm-linux-gnueabi libncurses5-dev build-essential bison flex libssl-dev bc && \ + apt-get install -y gcc-arm-linux-gnueabi g++-arm-linux-gnueabi && \ + apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf && \ + apt-get install -y g++-aarch64-linux-gnu crossbuild-essential-arm64 && \ + apt-get install -y gcc-13-aarch64-linux-gnu && \ + apt-get install -y g++-13-aarch64-linux-gnu && \ + apt-get install -y wget && \ + apt-get install -y curl && \ + apt-get install -y git + +RUN wget https://golang.org/dl/go1.21.1.linux-amd64.tar.gz && \ + tar -C /usr/local -xzf go1.21.1.linux-amd64.tar.gz && \ + rm go1.21.1.linux-amd64.tar.gz + +RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ + apt-get install -y nodejs + +RUN npm install -g pnpm + +RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash && \ + apt-get install -y git-lfs && \ + git lfs install + +# RUN npm install -g pnpm +RUN chmod +x /app/build.sh + +VOLUME [ "/data" ] +CMD ["/app/build.sh"] \ No newline at end of file diff --git a/docker/build/build.sh b/docker/build/build.sh new file mode 100644 index 00000000..dbb75448 --- /dev/null +++ b/docker/build/build.sh @@ -0,0 +1,16 @@ +#!/bin/bash +cd /app && \ +git clone https://github.com/yaoapp/kun.git /app/kun && \ +git clone https://github.com/yaoapp/xun.git /app/xun && \ +git clone https://github.com/yaoapp/gou.git /app/gou && \ +git clone https://github.com/yaoapp/v8go.git /app/v8go && \ +git clone https://github.com/yaoapp/xgen.git /app/xgen-v1.0 && \ +git clone https://github.com/yaoapp/yao-init.git /app/yao-init && \ +git clone https://github.com/yaoapp/yao.git /app/yao + + +cd /app/yao && \ +export VERSION=$(cat share/const.go |grep 'const VERSION' | awk '{print $4}' | sed "s/\"//g") + +cd /app/yao && make tools && make artifacts-linux +mv /app/yao/dist/release/* /data/ \ No newline at end of file