-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
130 lines (98 loc) · 3.51 KB
/
Dockerfile
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
129
130
FROM ubuntu:noble-20241118.1 AS init
ENV WORKDIR=/app
WORKDIR ${WORKDIR}
ENV VCPKG_ROOT=/opt/vcpkg
RUN apt-get -y update && \
apt-get -y install --no-install-recommends --no-install-suggests make && \
rm -rf /var/lib/apt/lists/*
FROM init AS builder
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/UTC
# build tools
RUN apt-get update \
&& apt-get -y install --no-install-recommends --no-install-suggests build-essential cmake g++ gcc make pkg-config \
&& rm -rf /var/lib/apt/lists/* \
&& make --version \
&& cmake --version \
&& gcc --version \
&& g++ --version
ENV VCPKG_FORCE_SYSTEM_BINARIES=1
# vcpkg Package Manager
ADD https://github.com/microsoft/vcpkg/archive/refs/tags/2024.10.21.tar.gz vcpkg.tar.gz
RUN apt-get -y update && \
apt-get -y install --no-install-recommends --no-install-suggests \
ca-certificates curl git ninja-build unzip zip && \
rm -rf /var/lib/apt/lists/* && \
mkdir /opt/vcpkg && \
tar xf vcpkg.tar.gz --strip-components=1 -C /opt/vcpkg && \
rm -rf vcpkg.tar.gz && \
/opt/vcpkg/bootstrap-vcpkg.sh && \
ln -s /opt/vcpkg/vcpkg /usr/local/bin/vcpkg && \
rm -rf /var/lib/apt/lists/* && \
vcpkg version
# sources
COPY ./src ${WORKDIR}/src
COPY ./vcpkg.json ${WORKDIR}/vcpkg.json
COPY ./CMakeLists.txt ${WORKDIR}/CMakeLists.txt
COPY ./CMakePresets.json ${WORKDIR}/CMakePresets.json
COPY ./Makefile ${WORKDIR}/
# dependencies
RUN make dependencies
LABEL vcpkg=enabled
# build
RUN ls -alhR && \
mkdir build && \
make build && \
ls -alhR
CMD ["make", "build"]
FROM builder AS development
# CMD []
FROM builder AS lint
RUN apt-get update && \
apt-get -y install --no-install-recommends --no-install-suggests gnupg software-properties-common && \
rm -rf /var/lib/apt/lists/*
ADD https://apt.llvm.org/llvm-snapshot.gpg.key llvm-snapshot.gpg.key
RUN apt-key add llvm-snapshot.gpg.key && \
apt-add-repository "deb https://apt.llvm.org/jammy/ llvm-toolchain-jammy main" && \
apt-get -y update && \
apt-get -y install --no-install-recommends --no-install-suggests clang-format && \
rm -rf /var/lib/apt/lists/*
ADD https://deb.nodesource.com/setup_22.x nodesource_setup.sh
RUN bash nodesource_setup.sh && \
apt-get -y install --no-install-recommends --no-install-suggests nodejs && \
npm install -g --ignore-scripts markdownlint-cli && \
apt-get -y install --no-install-recommends --no-install-suggests python3-minimal python3-pip && \
rm /usr/lib/python3.*/EXTERNALLY-MANAGED && \
pip install --no-cache-dir yamllint && \
apt-get -y install --no-install-recommends --no-install-suggests cppcheck && \
rm -rf /var/lib/apt/lists/*
# Code source
COPY ./src ${WORKDIR}/src
COPY ./vcpkg.json ${WORKDIR}/vcpkg.json
COPY ./CMakeLists.txt ${WORKDIR}/CMakeLists.txt
COPY ./CMakePresets.json ${WORKDIR}/CMakePresets.json
COPY ./Makefile ${WORKDIR}/
# markdownlint conf
COPY ./.markdownlint.yaml ${WORKDIR}/
# yamllint conf
COPY ./.yamllint ${WORKDIR}/
COPY ./.yamlignore ${WORKDIR}/
COPY ./.gitignore ${WORKDIR}/
CMD ["make", "lint"]
FROM development AS testing
RUN apt-get -y update && \
apt-get -y install --no-install-recommends --no-install-suggests lcov && \
rm -rf /var/lib/apt/lists/*
COPY --from=builder ${WORKDIR}/build ${WORKDIR}/
CMD ["make", "test"]
FROM ubuntu:noble-20241118.1 AS production
ENV LOG_LEVEL=INFO
ENV BRUTEFORCE=false
ENV WORKDIR=/app
WORKDIR ${WORKDIR}
# COPY ./Makefile ${WORKDIR}/
COPY --from=builder ${WORKDIR}/build/src/lib/exercises/*.a ${WORKDIR}/
RUN useradd --user-group --system --create-home --no-log-init app
USER app
RUN ls -alhR
CMD ["make", "run"]