feat: add pnpm and build stage in docker files

This commit is contained in:
abeimler 2023-04-17 11:14:02 +02:00
parent 7536d310d1
commit b61116bffa
10 changed files with 145 additions and 83 deletions

View File

@ -2,3 +2,4 @@
node_modules/ node_modules/
dev/docker/ dev/docker/
dev/container-tests/ dev/container-tests/
dist/

View File

@ -33,6 +33,7 @@ jobs:
include: include:
- node: 12 - node: 12
pnpm: 6 pnpm: 6
skip_test: true
- node: 16 - node: 16
pnpm: 7 pnpm: 7
- node: 18 - node: 18
@ -70,7 +71,7 @@ jobs:
# uses: mxschmitt/action-tmate@v3 # uses: mxschmitt/action-tmate@v3
- name: Test - name: Test
if: "!contains(github.event.head_commit.message, '[skip test]')" if: "${{ !contains(github.event.head_commit.message, '[skip test]') && !${{ matrix.skip_test }} }}"
run: | run: |
pnpm run test pnpm run test
continue-on-error: ${{ contains(matrix.os, 'ubuntu-18.04') }} continue-on-error: ${{ contains(matrix.os, 'ubuntu-18.04') }}
@ -113,11 +114,9 @@ jobs:
./exe/setup-cpp-x64-windows.exe ./exe/setup-cpp-x64-windows.exe
./exe/setup-cpp-x64-linux ./exe/setup-cpp-x64-linux
./exe/setup-cpp-x64-macos ./exe/setup-cpp-x64-macos
#./dist/node12/setup-cpp.js ./dist/node12/setup-cpp.js
#./dist/node12/setup-cpp.js.map ./dist/node12/setup-cpp.js.map
./dist/node12/ # TODO: deprecate node12 ./dist/node12/ # TODO: deprecate node12
./dist/node16/setup-cpp.js
./dist/node16/setup-cpp.js.map
./dist/node16/ ./dist/node16/
./dist/node18/ ./dist/node18/
@ -130,12 +129,12 @@ jobs:
os: os:
- ubuntu-22.04 - ubuntu-22.04
container: container:
- "ubuntu_node.dockerfile"
- "ubuntu_node_legacy.dockerfile"
- "ubuntu_20.04_node_legacy.dockerfile"
- "ubuntu_20.04_node.dockerfile"
- "arch_node.dockerfile" - "arch_node.dockerfile"
- "fedora_node.dockerfile" - "fedora_node.dockerfile"
- "ubuntu_20.04_node_legacy.dockerfile"
- "ubuntu_20.04_node.dockerfile"
- "ubuntu_node_legacy.dockerfile"
- "ubuntu_node.dockerfile"
cache_reset_counter: cache_reset_counter:
- 0 - 0
steps: steps:

@ -1 +1 @@
Subproject commit 467e5baf5e5caff2a6462581f7c2b0ca62d9af8c Subproject commit b10f2e841835b93cee67dff1eb70d6fa5c0ac0cd

View File

@ -4,35 +4,44 @@ FROM archlinux as base
RUN pacman -Syuu --noconfirm RUN pacman -Syuu --noconfirm
RUN pacman-db-upgrade RUN pacman-db-upgrade
# nodejs # install nodejs
RUN pacman -S --noconfirm --needed nodejs RUN pacman -S --noconfirm --needed nodejs
# curl for downloading setup-cpp # install pnpm
RUN pacman -S --noconfirm --needed curl #RUN pacman -S --noconfirm --needed pnpm
RUN npm install -g pnpm
#### Building
FROM base AS builder
## https://github.com/ever0de/pnpm-docker-root-bug#how-to-fix
WORKDIR /workspace
COPY . .
RUN pnpm install
#### setup-cpp
FROM base AS setup-cpp
# add setup-cpp.js # add setup-cpp.js
COPY "./dist/node16" "/" COPY --from=builder /workspace/dist/node18 /
WORKDIR "/"
# run installation # run installation
RUN node ./setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true RUN . $NVM_DIR/nvm.sh && node /setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true --powershell true
CMD ["source", "~/.cpprc"] CMD ["source", "~/.cpprc"]
ENTRYPOINT ["/bin/bash"] ENTRYPOINT ["/bin/bash"]
#### Building #### Building (example)
FROM base as builder FROM setup-cpp AS example-builder
COPY ./dev/cpp_vcpkg_project /home/app COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \ RUN bash -c 'source ~/.cpprc \
&& task build' && task build'
### Running environment #### Running environment
# use a distroless image or ubuntu:22.04 if you wish # use a distroless image or ubuntu:22.04 if you wish
FROM gcr.io/distroless/cc as runner FROM gcr.io/distroless/cc as runner
# copy the built binaries and their runtime dependencies # copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ COPY --from=example-builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/ WORKDIR /home/app/
ENTRYPOINT ["./my_exe"] ENTRYPOINT ["./my_exe"]

View File

@ -4,29 +4,40 @@ FROM fedora as base
# nodejs and curl for downloading setup-cpp # nodejs and curl for downloading setup-cpp
RUN dnf -y install nodejs curl RUN dnf -y install nodejs curl
# install pnpm
RUN npm install -g pnpm
#### Building
FROM base AS builder
## https://github.com/ever0de/pnpm-docker-root-bug#how-to-fix
WORKDIR /workspace
COPY . .
RUN pnpm install
#### setup-cpp
FROM base AS setup-cpp
# add setup-cpp.js # add setup-cpp.js
COPY "./dist/node16" "/" COPY --from=builder /workspace/dist/node18 /
WORKDIR "/"
# run installation # run installation
RUN node ./setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true --powershell true RUN . $NVM_DIR/nvm.sh && node /setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true --powershell true
CMD ["source", "~/.cpprc"] CMD ["source", "~/.cpprc"]
ENTRYPOINT ["/bin/bash"] ENTRYPOINT ["/bin/bash"]
#### Building #### Building (example)
FROM base as builder FROM setup-cpp AS example-builder
COPY ./dev/cpp_vcpkg_project /home/app COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \ RUN bash -c 'source ~/.cpprc \
&& task build' && task build'
### Running environment #### Running environment
# use a distroless image or ubuntu:22.04 if you wish # use a distroless image or ubuntu:22.04 if you wish
FROM gcr.io/distroless/cc as runner FROM gcr.io/distroless/cc as runner
# copy the built binaries and their runtime dependencies # copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ COPY --from=example-builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/ WORKDIR /home/app/
ENTRYPOINT ["./my_exe"] ENTRYPOINT ["./my_exe"]

View File

@ -19,30 +19,40 @@ RUN chmod +x /nvm_install.sh && /nvm_install.sh \
ENV NODE_PATH $NVM_DIR/v${node_version}/lib/node_modules ENV NODE_PATH $NVM_DIR/v${node_version}/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v${node_version}/bin:$PATH ENV PATH $NVM_DIR/versions/node/v${node_version}/bin:$PATH
# install pnpm
RUN npm install -g pnpm@7.32.0
#### Building
FROM base AS builder
## https://github.com/ever0de/pnpm-docker-root-bug#how-to-fix
WORKDIR /workspace
COPY . .
RUN pnpm install
#### setup-cpp
FROM base AS setup-cpp
# add setup-cpp.js # add setup-cpp.js
COPY "./dist/node16" "/" COPY --from=builder /workspace/dist/node16 /
WORKDIR "/"
# run installation # run installation
RUN node ./setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true RUN . $NVM_DIR/nvm.sh && node /setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true --powershell true
CMD ["source", "~/.cpprc"] CMD ["source", "~/.cpprc"]
ENTRYPOINT ["/bin/bash"] ENTRYPOINT ["/bin/bash"]
#### Building #### Building (example)
FROM base as builder FROM setup-cpp AS example-builder
COPY ./dev/cpp_vcpkg_project /home/app COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \ RUN bash -c 'source ~/.cpprc \
&& task build' && task build'
### Running environment #### Running environment
# use a distroless image or ubuntu:20.04 if you wish # use a distroless image or ubuntu:22.04 if you wish
FROM gcr.io/distroless/cc as runner FROM gcr.io/distroless/cc as runner
# copy the built binaries and their runtime dependencies # copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ COPY --from=example-builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/ WORKDIR /home/app/
ENTRYPOINT ["./my_exe"] ENTRYPOINT ["./my_exe"]

View File

@ -19,29 +19,40 @@ RUN chmod +x /nvm_install.sh && /nvm_install.sh \
ENV NODE_PATH $NVM_DIR/v${node_version}/lib/node_modules ENV NODE_PATH $NVM_DIR/v${node_version}/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v${node_version}/bin:$PATH ENV PATH $NVM_DIR/versions/node/v${node_version}/bin:$PATH
# install pnpm
RUN npm install -g pnpm@6.35.1
#### Building
FROM base AS builder
## https://github.com/ever0de/pnpm-docker-root-bug#how-to-fix
WORKDIR /workspace
COPY . .
RUN pnpm install
#### setup-cpp
FROM base AS setup-cpp
# add setup-cpp.js # add setup-cpp.js
COPY "./dist/node12" "/" COPY --from=builder /workspace/dist/node12 /
WORKDIR "/"
# run installation # run installation
RUN node ./setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true RUN . $NVM_DIR/nvm.sh && node /setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true --powershell true
CMD ["source", "~/.cpprc"] CMD ["source", "~/.cpprc"]
ENTRYPOINT ["/bin/bash"] ENTRYPOINT ["/bin/bash"]
#### Building #### Building (example)
FROM base as builder FROM setup-cpp AS example-builder
COPY ./dev/cpp_vcpkg_project /home/app COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \ RUN bash -c 'source ~/.cpprc \
&& task build' && task build'
### Running environment #### Running environment
# use a distroless image or ubuntu:20.04 if you wish # use a distroless image or ubuntu:22.04 if you wish
FROM gcr.io/distroless/cc as runner FROM gcr.io/distroless/cc as runner
# copy the built binaries and their runtime dependencies # copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ COPY --from=example-builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/ WORKDIR /home/app/
ENTRYPOINT ["./my_exe"] ENTRYPOINT ["./my_exe"]

View File

@ -6,8 +6,8 @@ ARG nvm_version="0.39.3"
ARG node_version="18.15.0" ARG node_version="18.15.0"
RUN mkdir /usr/local/nvm RUN mkdir /usr/local/nvm
ENV NVM_DIR /usr/local/nvm ENV NVM_DIR /usr/local/nvm
ADD https://raw.githubusercontent.com/nvm-sh/nvm/v${nvm_version}/install.sh /nvm_install.sh ADD https://raw.githubusercontent.com/nvm-sh/nvm/v${nvm_version}/install.sh /tmp/nvm_install.sh
RUN chmod +x /nvm_install.sh && /nvm_install.sh \ RUN chmod +x /tmp/nvm_install.sh && /tmp/nvm_install.sh \
&& . $NVM_DIR/nvm.sh \ && . $NVM_DIR/nvm.sh \
&& nvm install $node_version \ && nvm install $node_version \
&& nvm alias default $node_version \ && nvm alias default $node_version \
@ -15,29 +15,40 @@ RUN chmod +x /nvm_install.sh && /nvm_install.sh \
ENV NODE_PATH $NVM_DIR/v${node_version}/lib/node_modules ENV NODE_PATH $NVM_DIR/v${node_version}/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v${node_version}/bin:$PATH ENV PATH $NVM_DIR/versions/node/v${node_version}/bin:$PATH
# add setup-cpp.js # install pnpm
COPY "./dist/node16" "/" RUN npm install -g pnpm
WORKDIR "/"
# run installation
RUN . $NVM_DIR/nvm.sh && node ./setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true --powershell true
CMD ["source", "~/.cpprc"]
ENTRYPOINT [ "/bin/bash" ]
#### Building #### Building
FROM base AS builder FROM base AS builder
## https://github.com/ever0de/pnpm-docker-root-bug#how-to-fix
WORKDIR /workspace
COPY . .
RUN pnpm install
#### setup-cpp
FROM base AS setup-cpp
# add setup-cpp.js
COPY --from=builder /workspace/dist/node18 /
# run installation
RUN . $NVM_DIR/nvm.sh && node /setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true --powershell true
CMD ["source", "~/.cpprc"]
ENTRYPOINT ["/bin/bash"]
#### Building (example)
FROM setup-cpp AS example-builder
COPY ./dev/cpp_vcpkg_project /home/app COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \ RUN bash -c 'source ~/.cpprc \
&& task build' && task build'
### Running environment #### Running environment
# use a distroless image or ubuntu:22.04 if you wish # use a distroless image or ubuntu:22.04 if you wish
FROM gcr.io/distroless/cc as runner FROM gcr.io/distroless/cc as runner
# copy the built binaries and their runtime dependencies # copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ COPY --from=example-builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/ WORKDIR /home/app/
ENTRYPOINT ["./my_exe"] ENTRYPOINT ["./my_exe"]

View File

@ -3,29 +3,39 @@ FROM ubuntu:22.04 AS base
RUN apt-get update -qq RUN apt-get update -qq
RUN apt-get install -y --no-install-recommends nodejs RUN apt-get install -y --no-install-recommends nodejs
# install pnpm
RUN npm install -g pnpm@6.35.1
#### Building
FROM base AS builder
## https://github.com/ever0de/pnpm-docker-root-bug#how-to-fix
WORKDIR /workspace
COPY . .
RUN pnpm install
#### setup-cpp
FROM base AS setup-cpp
# add setup-cpp.js # add setup-cpp.js
COPY "./dist/node12" "/" COPY --from=builder /workspace/dist/node12 /
WORKDIR "/"
# run installation # run installation
RUN node ./setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true --powershell true RUN . $NVM_DIR/nvm.sh && node /setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true --powershell true
CMD ["source", "~/.cpprc"] CMD ["source", "~/.cpprc"]
ENTRYPOINT ["/bin/bash"] ENTRYPOINT ["/bin/bash"]
#### Building #### Building (example)
FROM base AS builder FROM setup-cpp AS example-builder
COPY ./dev/cpp_vcpkg_project /home/app COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \ RUN bash -c 'source ~/.cpprc \
&& task build' && task build'
### Running environment #### Running environment
# use a distroless image or ubuntu:22.04 if you wish # use a distroless image or ubuntu:22.04 if you wish
FROM gcr.io/distroless/cc as runner FROM gcr.io/distroless/cc as runner
# copy the built binaries and their runtime dependencies # copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ COPY --from=example-builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/ WORKDIR /home/app/
ENTRYPOINT ["./my_exe"] ENTRYPOINT ["./my_exe"]

View File

@ -55,9 +55,9 @@
"start.docker.fedora": "docker run -t setup-cpp:fedora .", "start.docker.fedora": "docker run -t setup-cpp:fedora .",
"start.docker.ubuntu": "docker run -t setup-cpp:ubuntu .", "start.docker.ubuntu": "docker run -t setup-cpp:ubuntu .",
"test": "run-p --continue-on-error test.lint test.unit", "test": "run-p --continue-on-error test.lint test.unit",
"test.docker.arch": "docker build -f ./dev/docker/arch_node.dockerfile --target base -t setup-cpp:arch-base . && container-structure-test test --image setup-cpp:arch-base --config ./dev/container-tests/arch.yml", "test.docker.arch": "docker build -f ./dev/docker/arch_node.dockerfile --target setup-cpp -t setup-cpp:arch-base . && container-structure-test test --image setup-cpp:arch-base --config ./dev/container-tests/arch.yml",
"test.docker.fedora": "docker build -f ./dev/docker/fedora_node.dockerfile --target base -t setup-cpp:fedora-base . && container-structure-test test --image setup-cpp:fedora-base --config ./dev/container-tests/fedora.yml", "test.docker.fedora": "docker build -f ./dev/docker/fedora_node.dockerfile --target setup-cpp -t setup-cpp:fedora-base . && container-structure-test test --image setup-cpp:fedora-base --config ./dev/container-tests/fedora.yml",
"test.docker.ubuntu": "docker build -f ./dev/docker/ubuntu_node.dockerfile --target base -t setup-cpp:ubuntu-base . && container-structure-test test --image setup-cpp:ubuntu-base --config ./dev/container-tests/ubuntu.yml", "test.docker.ubuntu": "docker build -f ./dev/docker/ubuntu_node.dockerfile --target setup-cpp -t setup-cpp:ubuntu-base . && container-structure-test test --image setup-cpp:ubuntu-base --config ./dev/container-tests/ubuntu.yml",
"test.lint": "run-p --aggregate-output --continue-on-error lint.cspell test.lint.eslint test.lint.prettier lint.tsc", "test.lint": "run-p --aggregate-output --continue-on-error lint.cspell test.lint.eslint test.lint.prettier lint.tsc",
"test.lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/", "test.lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/",
"test.lint.prettier": "prettier . --check", "test.lint.prettier": "prettier . --check",