docker: add building and running env to the dockers

This commit is contained in:
Amin Yahyaabadi 2022-04-26 22:33:36 -07:00
parent f9a84c82e8
commit e379435d81
5 changed files with 52 additions and 15 deletions

View File

@ -202,6 +202,8 @@ See [this folder](https://github.com/aminya/setup-cpp/tree/master/dev/docker), f
If you want to build the ones included, then run: If you want to build the ones included, then run:
```ps1 ```ps1
git clone --recurse-submodules https://github.com/aminya/setup-cpp
cd ./setup-cpp
docker build -f ./dev/docker/ubuntu.dockerfile -t setup_cpp . docker build -f ./dev/docker/ubuntu.dockerfile -t setup_cpp .
``` ```

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

View File

@ -1,4 +1,5 @@
FROM ubuntu:devel #### Base Image
FROM ubuntu:devel AS base
# add setup_cpp # add setup_cpp
WORKDIR "/" WORKDIR "/"
@ -8,9 +9,20 @@ 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 --vcpkg true RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --make true
# reload the environment
CMD source ~/.cpprc CMD source ~/.cpprc
ENTRYPOINT [ "/bin/sh" ] ENTRYPOINT [ "/bin/sh" ]
#### Building
FROM base AS builder
ADD ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN make build
### Running environment
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:devel FROM ubuntu:devel 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
@ -8,9 +8,20 @@ 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 && clang --version && cmake --version && ninja --version && ccache --version && cppcheck --version && vcpkg --version && doxygen --version && dot --version && gcovr --version
CMD source ~/.cpprc
ENTRYPOINT [ "/bin/sh" ] ENTRYPOINT [ "/bin/sh" ]
#### Building
FROM base AS builder
ADD ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN make build
### Running environment
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,20 @@ 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 && clang --version && cmake --version && ninja --version && ccache --version && cppcheck --version && vcpkg --version && doxygen --version && dot --version && gcovr --version
CMD source ~/.cpprc
ENTRYPOINT [ "/bin/sh" ] ENTRYPOINT [ "/bin/sh" ]
#### Building
FROM base AS builder
ADD ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN make build
### Running environment
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"]