-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile.ci
128 lines (104 loc) · 4.16 KB
/
Dockerfile.ci
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
## base image
FROM ubuntu:22.04 AS base
ARG extra_libraries
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update -yqq && \
apt-get install --no-install-recommends -y gnupg software-properties-common && \
add-apt-repository -y ppa:ubuntu-toolchain-r/test && \
apt-get update -y && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Install packages available from standard repos
RUN apt-get update -yqq && \
apt-get install --no-install-recommends -yq \
gcc wget curl pkg-config zip unzip tar git build-essential && \
apt-get install --no-install-recommends -y \
clang binutils bison \
${extra_libraries} \
python3 python3-pip doxygen graphviz \
cmake make ninja-build ccache cppcheck cmake-extras \
clang-tidy clang-format \
valgrind gcovr linux-tools-common linux-tools-generic google-perftools \
neovim emacs nano && \
apt-get clean && rm -rf /var/lib/apt/lists/*
#ADD https://apt.llvm.org/llvm.sh /tmp/llvm.sh
# Install conan
RUN python3 -m pip install --no-cache-dir conan==1.56.0 && \
conan --version
# Install more pip tools
RUN python3 -m pip install --no-cache-dir \
cogapp==3.3.0 \
coverage==7.0.3 \
cmake-format==0.6.13 \
cmakelint==1.4.2
# install task
ADD https://taskfile.dev/install.sh /tmp/taskfile_install.sh
RUN chmod +x /tmp/taskfile_install.sh
RUN /tmp/taskfile_install.sh -d -b /usr/local/bin && rm /tmp/taskfile_install.sh
# thx to https://github.com/lefticus/cpp_starter_project/pull/121
# By default, anything you run in Docker is done as superuser.
# Conan runs some install commands as superuser, and will prepend `sudo` to
# these commands, unless `CONAN_SYSREQUIRES_SUDO=0` is in your env variables.
ENV CONAN_SYSREQUIRES_SUDO 0
# Some packages request that Conan use the system package manager to install
# a few dependencies. This flag allows Conan to proceed with these installations;
# leaving this flag undefined can cause some installation failures.
ENV CONAN_SYSREQUIRES_MODE enabled
# set default compiler
ENV CC "gcc"
ENV CXX "g++"
ENV CMAKE "cmake"
ENV MAKE "ninja"
# setup project env
WORKDIR /home/project
## ci image
FROM base as ci-base
# default compiler versions
ARG extra_libraries
# Install packages available from standard repos
RUN apt-get update -y && \
apt-get install --no-install-recommends -y \
git ${extra_libraries} \
curl gnupg coreutils && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# install task
ADD https://taskfile.dev/install.sh /tmp/taskfile_install.sh
RUN chmod +x /tmp/taskfile_install.sh
RUN /tmp/taskfile_install.sh -d -b /usr/local/bin && rm /tmp/taskfile_install.sh
# install CodeCov
WORKDIR /home/codecov
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import
ADD https://uploader.codecov.io/latest/alpine/codecov codecov
ADD https://uploader.codecov.io/latest/alpine/codecov.SHA256SUM codecov.SHA256SUM
ADD https://uploader.codecov.io/latest/alpine/codecov.SHA256SUM.sig codecov.SHA256SUM.sig
RUN gpgv codecov.SHA256SUM.sig codecov.SHA256SUM && \
shasum -a 256 -c codecov.SHA256SUM && \
chmod +x codecov
ENV CODECOV "/home/codecov/codecov"
# set default compiler
ENV CC "gcc"
ENV CXX "g++"
ENV CMAKE "cmake"
ENV MAKE "ninja"
# install vcpkg
ENV VCPKG_DISABLE_METRICS 1
RUN git clone --depth 1 https://github.com/Microsoft/vcpkg.git /home/project/vcpkg && \
/home/project/vcpkg/bootstrap-vcpkg.sh -disableMetrics
ENV VCPKG_ROOT "/home/project/vcpkg"
ENV VCPKG_TOOLCHAIN_FILE "$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
ENV TOOLCHAIN_FILE "$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
# build script settings
ENV TARGET "all"
ENV BUILD_TYPE "Release"
ENV CMAKE_GENERATOR "Ninja Multi-Config"
ENV CMAKE_ARGS ""
# setup project env
WORKDIR /home/project
COPY ./scripts/docker-build.sh ./docker-build.sh
COPY ./scripts/docker-test.sh ./docker-test.sh
COPY ./scripts/docker-test-coverage.sh ./docker-test-coverage.sh
COPY ./taskfiles/*.yml /home/taskfiles/
COPY ./taskfiles/TaskfileDefault.yml /home/taskfiles/Taskfile.yml
ENV PROJECT_DIR /home/project
WORKDIR /home/project
RUN mkdir build