Merge pull request #63 from aminya/docker [skip ci]

This commit is contained in:
Amin Yahyaabadi 2022-04-26 23:05:54 -07:00 committed by GitHub
commit 9ce1b85f0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 111 additions and 49 deletions

View File

@ -1,4 +1,4 @@
{ {
"extends": "eslint-config-atomic", "extends": "eslint-config-atomic",
"ignorePatterns": ["dist/", "node_modules/"] "ignorePatterns": ["dist/", "node_modules/", "dev/cpp_vcpkg_project"]
} }

View File

@ -127,6 +127,6 @@ jobs:
- name: Build - name: Build
id: docker_build id: docker_build
run: | run: |
docker build -f ./building/docker/${{ matrix.container }} -t setup_cpp . docker build -f ./dev/docker/${{ matrix.container }} -t setup_cpp .
env: env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true ACTIONS_ALLOW_UNSECURE_COMMANDS: true

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "dev/cpp_vcpkg_project"]
path = dev/cpp_vcpkg_project
url = https://github.com/aminya/cpp_vcpkg_project

View File

@ -6,3 +6,4 @@ dist
stats.html stats.html
src/python/setup-python/ src/python/setup-python/
src/msvc/msvc-dev-cmd/ src/msvc/msvc-dev-cmd/
dev/cpp_vcpkg_project

View File

@ -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. Here is an example for using setup_cpp to make a builder image that has the Cpp tools you need.
```dockerfile ```dockerfile
FROM ubuntu:devel #### Base Image
FROM ubuntu:devel AS base
# add setup_cpp # add setup_cpp
WORKDIR "/" WORKDIR "/"
@ -189,20 +190,35 @@ RUN wget --no-verbose "https://github.com/aminya/setup-cpp/releases/download/v0.
RUN chmod +x ./setup_cpp_linux RUN chmod +x ./setup_cpp_linux
# install llvm, cmake, ninja, and ccache # 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 CMD source ~/.cpprc
RUN 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: If you want to build the ones included, then run:
```ps1 ```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`. Where you should use the path to the dockerfile after `-f`.
@ -230,7 +246,7 @@ jobs:
- name: Build - name: Build
id: docker_build id: docker_build
run: | run: |
docker build -f ./building/docker/debian.dockerfile -t setup_cpp . docker build -f ./dev/docker/debian.dockerfile -t setup_cpp .
env: env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true ACTIONS_ALLOW_UNSECURE_COMMANDS: true
``` ```

View File

@ -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" ]

View File

@ -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" ]

View File

@ -7,6 +7,7 @@ ignorePaths:
- pnpm-lock.yaml - pnpm-lock.yaml
- .git/ - .git/
- dist/ - dist/
- dev/cpp_vcpkg_project
words: words:
- aarch - aarch
- aminya - aminya

1
dev/cpp_vcpkg_project Submodule

@ -0,0 +1 @@
Subproject commit f4fe216401a8eac95d66969f0ee2b760b3c4edf0

View File

@ -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"]

View File

@ -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"]

View File

@ -1,4 +1,4 @@
FROM ubuntu:20.04 FROM ubuntu:20.04 AS base
# set time-zone # set time-zone
ENV TZ=Canada/Pacific ENV TZ=Canada/Pacific
@ -16,9 +16,22 @@ ADD "./dist/" "/"
WORKDIR "/" 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 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
CMD source ~/.cpprc && clang --version && cmake --version && ninja --version && ccache --version && cppcheck --version && vcpkg --version && doxygen --version && dot --version && gcovr --version 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: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"]

View File

@ -13,7 +13,7 @@
}, },
"scripts": { "scripts": {
"build": "run-p test.tsc build.parcel copy.matchers", "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", "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", "bump": "ncu -u -x execa && pnpm update",
"clean": "shx rm -rf .parcel-cache dist exe", "clean": "shx rm -rf .parcel-cache dist exe",
@ -21,7 +21,7 @@
"dev": "cross-env NODE_ENV=development parcel watch", "dev": "cross-env NODE_ENV=development parcel watch",
"format": "prettier --write .", "format": "prettier --write .",
"lint": "eslint . --fix", "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", "prepare": "npm run build",
"start.docker": "docker run -t setup_cpp .", "start.docker": "docker run -t setup_cpp .",
"test": "run-p test.format test.lint test.cspell test.tsc test.unit", "test": "run-p test.format test.lint test.cspell test.tsc test.unit",