diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..fb76a282 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +# 排除特定文件 +output/ diff --git a/.gitignore b/.gitignore index 73551262..cd2db43b 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,6 @@ dist/ pubspec.lock Podfile.lock + +#docker +output/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..9cfbc51b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM gcc:11.5.0 AS builder + +RUN apt-get update && apt-get install cmake -y + +WORKDIR /MMKV + +COPY . . + +## 设置环境变量 +#ENV CGO_ENABLED='1' +#ENV CGO_CFLAGS='-static -O2 -g' +#ENV CGO_LDFLAGS='-static -O2 -g' + +WORKDIR /MMKV/POSIX/golang +RUN mkdir -p build && cd build && rm -rf ./* && \ + cmake .. -DCMAKE_INSTALL_PREFIX=. \ + -DCMAKE_BUILD_TYPE=Release && \ + make -j8 install + +RUN uname -a > /MMKV/POSIX/golang/build/tencent.com/build_info.txt 2>&1 && \ + gcc -v >> /MMKV/POSIX/golang/build/tencent.com/build_info.txt 2>&1 && \ + cmake --version >> /MMKV/POSIX/golang/build/tencent.com/build_info.txt 2>&1 + +FROM scratch AS export-stage +COPY --from=builder /MMKV/POSIX/golang/build/tencent.com /tencent.com diff --git a/Makefile b/Makefile index 3857df0e..0e4fbe7e 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,6 @@ format_code: - python Script/formatCode.py \ No newline at end of file + python Script/formatCode.py + +golang: + docker pull --platform=$(PLATFORM) gcc:11.5.0 + docker buildx build --platform=$(PLATFORM) --target export-stage --output type=local,dest=./output/$(PLATFORM) . \ No newline at end of file