diff --git a/.eslintrc.json b/.eslintrc.json index 2f460539..7d6c702d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,4 +1,4 @@ { "extends": "eslint-config-atomic", - "ignorePatterns": ["dist/", "node_modules/"] + "ignorePatterns": ["dist/", "node_modules/", "dev/cpp_vcpkg_project"] } diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b3cd0b4d..89bb57fc 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -127,6 +127,6 @@ jobs: - name: Build id: docker_build run: | - docker build -f ./building/docker/${{ matrix.container }} -t setup_cpp . + docker build -f ./dev/docker/${{ matrix.container }} -t setup_cpp . env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..7d28b8b0 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "dev/cpp_vcpkg_project"] + path = dev/cpp_vcpkg_project + url = https://github.com/aminya/cpp_vcpkg_project diff --git a/.prettierignore b/.prettierignore index 833fbbde..1f9b46de 100644 --- a/.prettierignore +++ b/.prettierignore @@ -6,3 +6,4 @@ dist stats.html src/python/setup-python/ src/msvc/msvc-dev-cmd/ +dev/cpp_vcpkg_project diff --git a/README.md b/README.md index 9c97ee27..fa456a5d 100644 --- a/README.md +++ b/README.md @@ -179,7 +179,8 @@ jobs: Here is an example for using setup_cpp to make a builder image that has the Cpp tools you need. ```dockerfile -FROM ubuntu:devel +#### Base Image +FROM ubuntu:devel AS base # add setup_cpp WORKDIR "/" @@ -189,20 +190,35 @@ RUN wget --no-verbose "https://github.com/aminya/setup-cpp/releases/download/v0. RUN chmod +x ./setup_cpp_linux # install llvm, cmake, ninja, and ccache -RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true +RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --make true -# activate cpp environment variables -RUN source ~/.cpprc +CMD source ~/.cpprc +ENTRYPOINT [ "/bin/bash" ] -ENTRYPOINT [ "/bin/sh" ] +#### Building +FROM base AS builder +ADD ./dev/cpp_vcpkg_project /home/app +WORKDIR /home/app +RUN bash -c 'source ~/.cpprc \ + && make build' + +### Running environment +# use a distroless image or ubuntu:devel if you wish +FROM gcr.io/distroless/cc +# copy the built binaries and their runtime dependencies +COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ +WORKDIR /home/app/ +ENTRYPOINT ["./my_exe"] ``` -See [this folder](https://github.com/aminya/setup-cpp/tree/master/building/docker), for some dockerfile examples. +See [this folder](https://github.com/aminya/setup-cpp/tree/master/dev/docker), for some dockerfile examples. If you want to build the ones included, then run: ```ps1 -docker build -f ./building/docker/ubuntu.dockerfile -t setup_cpp . +git clone --recurse-submodules https://github.com/aminya/setup-cpp +cd ./setup-cpp +docker build -f ./dev/docker/ubuntu.dockerfile -t setup_cpp . ``` Where you should use the path to the dockerfile after `-f`. @@ -230,7 +246,7 @@ jobs: - name: Build id: docker_build run: | - docker build -f ./building/docker/debian.dockerfile -t setup_cpp . + docker build -f ./dev/docker/debian.dockerfile -t setup_cpp . env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true ``` diff --git a/building/docker/ubuntu.dockerfile b/building/docker/ubuntu.dockerfile deleted file mode 100644 index d0dff673..00000000 --- a/building/docker/ubuntu.dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM ubuntu:devel - -# add setup_cpp -WORKDIR "/" -RUN apt-get update -qq -RUN apt-get install -y --no-install-recommends wget -RUN wget --no-verbose "https://github.com/aminya/setup-cpp/releases/download/v0.13.1/setup_cpp_linux" -RUN chmod +x ./setup_cpp_linux - -# install llvm, cmake, ninja, and ccache -RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true - -# reload the environment -CMD source ~/.cpprc - -ENTRYPOINT [ "/bin/sh" ] diff --git a/building/docker/ubuntu_node.dockerfile b/building/docker/ubuntu_node.dockerfile deleted file mode 100644 index 29d53ec7..00000000 --- a/building/docker/ubuntu_node.dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM ubuntu:devel - -RUN apt-get update -qq -RUN apt-get install -y --no-install-recommends nodejs - -# add setup_cpp.js -ADD "./dist/" "/" -WORKDIR "/" - -# run installation -RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true - -# reload the environment and print the versions -CMD source ~/.cpprc && clang --version && cmake --version && ninja --version && ccache --version && cppcheck --version && vcpkg --version && doxygen --version && dot --version && gcovr --version - -ENTRYPOINT [ "/bin/sh" ] \ No newline at end of file diff --git a/cspell.config.yaml b/cspell.config.yaml index 9c9269e2..346c65a0 100644 --- a/cspell.config.yaml +++ b/cspell.config.yaml @@ -7,6 +7,7 @@ ignorePaths: - pnpm-lock.yaml - .git/ - dist/ + - dev/cpp_vcpkg_project words: - aarch - aminya diff --git a/dev/cpp_vcpkg_project b/dev/cpp_vcpkg_project new file mode 160000 index 00000000..f4fe2164 --- /dev/null +++ b/dev/cpp_vcpkg_project @@ -0,0 +1 @@ +Subproject commit f4fe216401a8eac95d66969f0ee2b760b3c4edf0 diff --git a/dev/docker/ubuntu.dockerfile b/dev/docker/ubuntu.dockerfile new file mode 100644 index 00000000..e1e9ed09 --- /dev/null +++ b/dev/docker/ubuntu.dockerfile @@ -0,0 +1,30 @@ +#### Base Image +FROM ubuntu:devel AS base + +# add setup_cpp +WORKDIR "/" +RUN apt-get update -qq +RUN apt-get install -y --no-install-recommends wget +RUN wget --no-verbose "https://github.com/aminya/setup-cpp/releases/download/v0.13.1/setup_cpp_linux" +RUN chmod +x ./setup_cpp_linux + +# install llvm, cmake, ninja, and ccache +RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --make true + +CMD source ~/.cpprc +ENTRYPOINT [ "/bin/bash" ] + +#### Building +FROM base AS builder +ADD ./dev/cpp_vcpkg_project /home/app +WORKDIR /home/app +RUN bash -c 'source ~/.cpprc \ + && make build' + +### Running environment +# use a distroless image or ubuntu:devel if you wish +FROM gcr.io/distroless/cc +# copy the built binaries and their runtime dependencies +COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ +WORKDIR /home/app/ +ENTRYPOINT ["./my_exe"] diff --git a/dev/docker/ubuntu_node.dockerfile b/dev/docker/ubuntu_node.dockerfile new file mode 100644 index 00000000..1bbd70be --- /dev/null +++ b/dev/docker/ubuntu_node.dockerfile @@ -0,0 +1,29 @@ +FROM ubuntu:devel AS base + +RUN apt-get update -qq +RUN apt-get install -y --no-install-recommends nodejs + +# add setup_cpp.js +ADD "./dist/" "/" +WORKDIR "/" + +# run installation +RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --make true + +CMD source ~/.cpprc +ENTRYPOINT [ "/bin/bash" ] + +#### Building +FROM base AS builder +ADD ./dev/cpp_vcpkg_project /home/app +WORKDIR /home/app +RUN bash -c 'source ~/.cpprc \ + && make build' + +### Running environment +# use a distroless image or ubuntu:devel if you wish +FROM gcr.io/distroless/cc +# copy the built binaries and their runtime dependencies +COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ +WORKDIR /home/app/ +ENTRYPOINT ["./my_exe"] diff --git a/building/docker/ubuntu_stable_node.dockerfile b/dev/docker/ubuntu_stable_node.dockerfile similarity index 55% rename from building/docker/ubuntu_stable_node.dockerfile rename to dev/docker/ubuntu_stable_node.dockerfile index 717de80f..b4120ac7 100644 --- a/building/docker/ubuntu_stable_node.dockerfile +++ b/dev/docker/ubuntu_stable_node.dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:20.04 +FROM ubuntu:20.04 AS base # set time-zone ENV TZ=Canada/Pacific @@ -16,9 +16,22 @@ ADD "./dist/" "/" WORKDIR "/" # run installation -RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true +RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --make true -# reload the environment and print the versions -CMD source ~/.cpprc && clang --version && cmake --version && ninja --version && ccache --version && cppcheck --version && vcpkg --version && doxygen --version && dot --version && gcovr --version +CMD source ~/.cpprc +ENTRYPOINT [ "/bin/bash" ] -ENTRYPOINT [ "/bin/sh" ] \ No newline at end of file +#### Building +FROM base AS builder +ADD ./dev/cpp_vcpkg_project /home/app +WORKDIR /home/app +RUN bash -c 'source ~/.cpprc \ + && make build' + +### Running environment +# use a distroless image or ubuntu:20.04 if you wish +FROM gcr.io/distroless/cc +# copy the built binaries and their runtime dependencies +COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ +WORKDIR /home/app/ +ENTRYPOINT ["./my_exe"] diff --git a/building/scripts/debug_remove.js b/dev/scripts/debug_remove.js similarity index 100% rename from building/scripts/debug_remove.js rename to dev/scripts/debug_remove.js diff --git a/building/scripts/pack-exe.js b/dev/scripts/pack-exe.js similarity index 100% rename from building/scripts/pack-exe.js rename to dev/scripts/pack-exe.js diff --git a/package.json b/package.json index e326a34a..a026608e 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "scripts": { "build": "run-p test.tsc build.parcel copy.matchers", - "build.docker": "pnpm build && docker build -f ./building/docker/ubuntu_node.dockerfile -t setup_cpp .", + "build.docker": "pnpm build && docker build -f ./dev/docker/ubuntu_node.dockerfile -t setup_cpp .", "build.parcel": "shx rm -rf ./dist/*.js ./dist/*.js.map && cross-env NODE_ENV=production parcel build --detailed-report", "bump": "ncu -u -x execa && pnpm update", "clean": "shx rm -rf .parcel-cache dist exe", @@ -21,7 +21,7 @@ "dev": "cross-env NODE_ENV=development parcel watch", "format": "prettier --write .", "lint": "eslint . --fix", - "pack.exe": "shx rm -rf ./dist/tsconfig.tsbuildinfo && node ./building/scripts/pack-exe.js", + "pack.exe": "shx rm -rf ./dist/tsconfig.tsbuildinfo && node ./dev/scripts/pack-exe.js", "prepare": "npm run build", "start.docker": "docker run -t setup_cpp .", "test": "run-p test.format test.lint test.cspell test.tsc test.unit",