mirror of https://github.com/aminya/setup-cpp
feat: add separate production and testing docker files
This commit is contained in:
parent
78e0cf33cc
commit
73478bbe8c
|
@ -1,5 +1,20 @@
|
||||||
.parcel-cache/
|
.git/
|
||||||
node_modules/
|
# OS metadata
|
||||||
dev/docker/
|
**/.DS_Store
|
||||||
dev/container-tests/
|
**/Thumbs.db
|
||||||
dist/
|
|
||||||
|
# Node
|
||||||
|
**/node_modules
|
||||||
|
**/package-lock.json
|
||||||
|
**/temp-*
|
||||||
|
|
||||||
|
# TypeScript
|
||||||
|
**/*.tsbuildinfo
|
||||||
|
|
||||||
|
# Build directories
|
||||||
|
**/packages/*/dist/
|
||||||
|
**/.parcel-cache
|
||||||
|
**/exe/
|
||||||
|
**/*.log
|
||||||
|
**/*.exe
|
||||||
|
**/.cache/
|
||||||
|
|
|
@ -132,10 +132,14 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
- ubuntu-22.04
|
- ubuntu-22.04
|
||||||
|
node:
|
||||||
|
- 18
|
||||||
|
pnpm:
|
||||||
|
- 8
|
||||||
container:
|
container:
|
||||||
- "arch_node.dockerfile"
|
- "./dev/docker/__tests__/arch.dockerfile"
|
||||||
- "fedora_node.dockerfile"
|
- "./dev/docker/__tests__/fedora.dockerfile"
|
||||||
- "ubuntu_node.dockerfile"
|
- "./dev/docker/__tests__/ubuntu.dockerfile"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
|
@ -151,7 +155,21 @@ jobs:
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
"setupcpp-docker-cache-OS:${{ matrix.os }}"
|
"setupcpp-docker-cache-OS:${{ matrix.os }}"
|
||||||
|
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node }}
|
||||||
|
|
||||||
|
- name: Setup Pnpm
|
||||||
|
uses: pnpm/action-setup@v2
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.pnpm }}
|
||||||
|
|
||||||
|
- name: Install and build
|
||||||
|
run: |
|
||||||
|
pnpm install
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
id: docker_build
|
id: docker_build
|
||||||
run: |
|
run: |
|
||||||
docker build -f ./dev/docker/${{ matrix.container }} -t setup-cpp .
|
docker build -f ${{ matrix.container }} -t setup-cpp .
|
||||||
|
|
26
README.md
26
README.md
|
@ -153,29 +153,29 @@ Here is an example for using setup-cpp to make a builder image that has the Cpp
|
||||||
|
|
||||||
```dockerfile
|
```dockerfile
|
||||||
#### Base Image
|
#### Base Image
|
||||||
FROM ubuntu:22.04 AS base
|
FROM ubuntu:22.04 as base
|
||||||
|
|
||||||
# add setup-cpp
|
# install nodejs and setup-cpp
|
||||||
RUN apt-get update -qq
|
RUN apt-get update -qq && \
|
||||||
RUN apt-get install -y --no-install-recommends npm
|
apt-get install -y --no-install-recommends nodejs npm && \
|
||||||
RUN npm install -g setup-cpp
|
npm install -g setup-cpp
|
||||||
|
|
||||||
# install llvm, cmake, ninja, and ccache
|
# install llvm, cmake, ninja, and ccache
|
||||||
RUN setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --make true
|
RUN setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --task true
|
||||||
|
|
||||||
CMD source ~/.cpprc
|
|
||||||
ENTRYPOINT ["/bin/bash"]
|
ENTRYPOINT ["/bin/bash"]
|
||||||
|
|
||||||
#### Building
|
#### Building (example)
|
||||||
FROM base AS builder
|
FROM base as builder
|
||||||
ADD ./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 \
|
||||||
&& make 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
|
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=builder /home/app/build/my_exe/Release/ /home/app/
|
||||||
WORKDIR /home/app/
|
WORKDIR /home/app/
|
||||||
|
@ -217,7 +217,7 @@ jobs:
|
||||||
- name: Build
|
- name: Build
|
||||||
id: docker_build
|
id: docker_build
|
||||||
run: |
|
run: |
|
||||||
docker build -f ./dev/docker/debian.dockerfile -t setup-cpp .
|
docker build -f ./dev/docker/ubuntu.dockerfile -t setup-cpp .
|
||||||
```
|
```
|
||||||
|
|
||||||
### Inside GitLab pipelines
|
### Inside GitLab pipelines
|
||||||
|
|
|
@ -1,28 +1,18 @@
|
||||||
## base image
|
## base image
|
||||||
FROM archlinux as base
|
FROM archlinux as base
|
||||||
|
|
||||||
# install nodejs and pnpm
|
# install nodejs
|
||||||
RUN pacman -Syuu --noconfirm && pacman-db-upgrade && pacman -S --noconfirm --needed nodejs npm git \
|
RUN pacman -Syuu --noconfirm && \
|
||||||
&& npm install -g pnpm
|
pacman-db-upgrade && \
|
||||||
|
pacman -S --noconfirm --needed nodejs
|
||||||
|
|
||||||
|
# add setup-cpp.js (built outside of this dockerfile)
|
||||||
|
COPY "./dist/node18" "/"
|
||||||
|
|
||||||
#### 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
|
|
||||||
COPY --from=builder /workspace/dist/node18 /
|
|
||||||
# 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 node /setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true
|
||||||
CMD ["source", "~/.cpprc"]
|
|
||||||
ENTRYPOINT ["/bin/bash"]
|
|
||||||
|
|
||||||
|
ENTRYPOINT ["/bin/bash"]
|
||||||
|
|
||||||
#### Building (example)
|
#### Building (example)
|
||||||
FROM setup-cpp AS example-builder
|
FROM setup-cpp AS example-builder
|
||||||
|
@ -31,7 +21,6 @@ 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
|
|
@ -1,28 +1,17 @@
|
||||||
## base image
|
## base image
|
||||||
FROM fedora as base
|
FROM fedora as base
|
||||||
|
|
||||||
# nodejs and curl for downloading setup-cpp
|
# install nodejs and setup-cpp
|
||||||
RUN dnf -y install nodejs npm curl git && dnf clean all \
|
RUN dnf -y install nodejs npm && \
|
||||||
&& npm install -g pnpm
|
npm install -g setup-cpp
|
||||||
|
|
||||||
|
# add setup-cpp.js (built outside of this dockerfile)
|
||||||
|
COPY "./dist/node18" "/"
|
||||||
|
|
||||||
#### 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
|
|
||||||
COPY --from=builder /workspace/dist/node18 /
|
|
||||||
# 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 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"]
|
|
||||||
|
|
||||||
|
ENTRYPOINT ["/bin/bash"]
|
||||||
|
|
||||||
#### Building (example)
|
#### Building (example)
|
||||||
FROM setup-cpp AS example-builder
|
FROM setup-cpp AS example-builder
|
||||||
|
@ -31,7 +20,6 @@ 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
|
|
@ -0,0 +1,30 @@
|
||||||
|
#### Base Image
|
||||||
|
FROM ubuntu:22.04 as base
|
||||||
|
|
||||||
|
# install nodejs and setup-cpp
|
||||||
|
RUN apt-get update -qq && \
|
||||||
|
apt-get install -y --no-install-recommends nodejs
|
||||||
|
|
||||||
|
# add setup-cpp.js (built outside of this dockerfile)
|
||||||
|
COPY "./dist/node18" "/"
|
||||||
|
|
||||||
|
# install setup-cpp
|
||||||
|
RUN node /setup-cpp.js --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --task true
|
||||||
|
|
||||||
|
ENTRYPOINT ["/bin/bash"]
|
||||||
|
|
||||||
|
#### Building
|
||||||
|
FROM base as builder
|
||||||
|
COPY ./dev/cpp_vcpkg_project /home/app
|
||||||
|
WORKDIR /home/app
|
||||||
|
RUN bash -c 'source ~/.cpprc \
|
||||||
|
&& task build'
|
||||||
|
|
||||||
|
|
||||||
|
### Running environment
|
||||||
|
# use a distroless image or ubuntu:22.04 if you wish
|
||||||
|
FROM gcr.io/distroless/cc as runner
|
||||||
|
# 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"]
|
|
@ -0,0 +1,28 @@
|
||||||
|
## base image
|
||||||
|
FROM archlinux as base
|
||||||
|
|
||||||
|
# install nodejs and setup-cpp
|
||||||
|
RUN pacman -Syuu --noconfirm && \
|
||||||
|
pacman-db-upgrade && \
|
||||||
|
pacman -S --noconfirm --needed nodejs npm && \
|
||||||
|
npm install -g setup-cpp
|
||||||
|
|
||||||
|
# run installation
|
||||||
|
RUN setup-cpp --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true
|
||||||
|
|
||||||
|
ENTRYPOINT ["/bin/bash"]
|
||||||
|
|
||||||
|
#### Building (example)
|
||||||
|
FROM base AS example-builder
|
||||||
|
COPY ./dev/cpp_vcpkg_project /home/app
|
||||||
|
WORKDIR /home/app
|
||||||
|
RUN bash -c 'source ~/.cpprc \
|
||||||
|
&& task build'
|
||||||
|
|
||||||
|
#### Running environment
|
||||||
|
# use a distroless image or ubuntu:22.04 if you wish
|
||||||
|
FROM gcr.io/distroless/cc as runner
|
||||||
|
# copy the built binaries and their runtime dependencies
|
||||||
|
COPY --from=example-builder /home/app/build/my_exe/Release/ /home/app/
|
||||||
|
WORKDIR /home/app/
|
||||||
|
ENTRYPOINT ["./my_exe"]
|
|
@ -0,0 +1,26 @@
|
||||||
|
## base image
|
||||||
|
FROM fedora as base
|
||||||
|
|
||||||
|
# install nodejs and setup-cpp
|
||||||
|
RUN dnf -y install nodejs npm && \
|
||||||
|
npm install -g setup-cpp
|
||||||
|
|
||||||
|
# run installation
|
||||||
|
RUN setup-cpp --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true --powershell true
|
||||||
|
|
||||||
|
ENTRYPOINT ["/bin/bash"]
|
||||||
|
|
||||||
|
#### Building (example)
|
||||||
|
FROM base AS example-builder
|
||||||
|
COPY ./dev/cpp_vcpkg_project /home/app
|
||||||
|
WORKDIR /home/app
|
||||||
|
RUN bash -c 'source ~/.cpprc \
|
||||||
|
&& task build'
|
||||||
|
|
||||||
|
#### Running environment
|
||||||
|
# use a distroless image or ubuntu:22.04 if you wish
|
||||||
|
FROM gcr.io/distroless/cc as runner
|
||||||
|
# copy the built binaries and their runtime dependencies
|
||||||
|
COPY --from=example-builder /home/app/build/my_exe/Release/ /home/app/
|
||||||
|
WORKDIR /home/app/
|
||||||
|
ENTRYPOINT ["./my_exe"]
|
|
@ -1,17 +1,17 @@
|
||||||
#### Base Image
|
#### Base Image
|
||||||
FROM ubuntu:22.04 as base
|
FROM ubuntu:22.04 as base
|
||||||
|
|
||||||
# install setup-cpp
|
# install nodejs and setup-cpp
|
||||||
RUN apt-get update -qq && apt-get install -y --no-install-recommends npm git curl && rm -rf /var/lib/apt/lists/* \
|
RUN apt-get update -qq && \
|
||||||
&& npm install -g setup-cpp \
|
apt-get install -y --no-install-recommends nodejs npm && \
|
||||||
# install llvm, cmake, ninja, and ccache
|
npm install -g setup-cpp
|
||||||
&& setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --task true
|
|
||||||
|
# install llvm, cmake, ninja, and ccache
|
||||||
|
RUN setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --task true
|
||||||
|
|
||||||
CMD ["source", "~/.cpprc"]
|
|
||||||
ENTRYPOINT ["/bin/bash"]
|
ENTRYPOINT ["/bin/bash"]
|
||||||
|
|
||||||
|
#### Building (example)
|
||||||
#### Building
|
|
||||||
FROM base as builder
|
FROM base as builder
|
||||||
COPY ./dev/cpp_vcpkg_project /home/app
|
COPY ./dev/cpp_vcpkg_project /home/app
|
||||||
WORKDIR /home/app
|
WORKDIR /home/app
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
FROM ubuntu:22.04 AS base
|
|
||||||
|
|
||||||
# install node with nvm
|
|
||||||
RUN apt-get update -qq && apt-get install -y --no-install-recommends git curl wget ca-certificates && rm -rf /var/lib/apt/lists/*
|
|
||||||
ARG nvm_version="0.39.3"
|
|
||||||
ARG node_version="18.15.0"
|
|
||||||
ENV NVM_DIR /usr/local/nvm
|
|
||||||
RUN mkdir $NVM_DIR
|
|
||||||
ADD https://raw.githubusercontent.com/nvm-sh/nvm/v${nvm_version}/install.sh /tmp/nvm_install.sh
|
|
||||||
RUN chmod +x /tmp/nvm_install.sh && /tmp/nvm_install.sh \
|
|
||||||
&& . $NVM_DIR/nvm.sh \
|
|
||||||
&& nvm install $node_version \
|
|
||||||
&& nvm alias default $node_version \
|
|
||||||
&& nvm use default
|
|
||||||
ENV NODE_PATH $NVM_DIR/v${node_version}/lib/node_modules
|
|
||||||
ENV PATH $NVM_DIR/versions/node/v${node_version}/bin:$PATH
|
|
||||||
|
|
||||||
# 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
|
|
||||||
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
|
|
||||||
WORKDIR /home/app
|
|
||||||
RUN bash -c 'source ~/.cpprc \
|
|
||||||
&& task build'
|
|
||||||
|
|
||||||
|
|
||||||
#### Running environment
|
|
||||||
# use a distroless image or ubuntu:22.04 if you wish
|
|
||||||
FROM gcr.io/distroless/cc as runner
|
|
||||||
# copy the built binaries and their runtime dependencies
|
|
||||||
COPY --from=example-builder /home/app/build/my_exe/Release/ /home/app/
|
|
||||||
WORKDIR /home/app/
|
|
||||||
ENTRYPOINT ["./my_exe"]
|
|
Loading…
Reference in New Issue