-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
122 lines (103 loc) · 4.87 KB
/
Copy pathDockerfile
File metadata and controls
122 lines (103 loc) · 4.87 KB
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
# =============================================================================
# diametercodec multi-stage Dockerfile
# =============================================================================
# Single file replacing the inherited chain: ubuntu -> diametercodec_builder
# All dependency versions are declared as ARGs here (single source of truth).
#
# Stages:
# deps - All third-party libraries compiled and installed
# build - Project compilation (library + examples)
# unit-test - Lightweight image for running unit tests
#
# Usage:
# docker build --target deps -t diametercodec_builder .
# docker build --target build -t diametercodec_build .
# docker build --target unit-test -t diametercodec_ut .
#
# The build.sh script handles all of this automatically.
# =============================================================================
FROM ubuntu:24.04 AS deps
LABEL maintainer="testillano"
LABEL testillano.diametercodec_builder.description="Docker image with all dependencies to build ert_diametercodec library"
WORKDIR /code/build
# ---------------------------------------------------------------------------
# Dependency versions (single source of truth)
# ---------------------------------------------------------------------------
ARG make_procs=4
ARG build_type=Release
ARG ert_logger_ver=v1.1.1
ARG nlohmann_json_ver=v3.12.0
ARG pboettch_jsonschemavalidator_ver=2.4.0
ARG google_test_ver=v1.11.0
# ---------------------------------------------------------------------------
# System packages
# ---------------------------------------------------------------------------
RUN apt-get update && apt-get install -y \
wget tar \
make cmake g++ \
libssl-dev zlib1g-dev \
doxygen graphviz \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# ===========================================================================
# ERT_LOGGER
# ===========================================================================
RUN set -x && \
wget https://github.com/testillano/logger/archive/${ert_logger_ver}.tar.gz && \
tar xvf ${ert_logger_ver}.tar.gz && cd logger-*/ && \
cmake -DERT_LOGGER_BuildExamples=OFF -DCMAKE_BUILD_TYPE=${build_type} . && \
make -j${make_procs} && make install && \
cd .. && rm -rf * && \
set +x
# ===========================================================================
# NLOHMANN JSON
# ===========================================================================
RUN set -x && \
wget https://github.com/nlohmann/json/archive/refs/tags/${nlohmann_json_ver}.tar.gz && \
tar xvf ${nlohmann_json_ver}.tar.gz && cd json-*/ && mkdir build && cd build && \
cmake -DJSON_BuildTests=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5 .. && \
make -j${make_procs} install && \
cd ../.. && rm -rf * && \
set +x
# ===========================================================================
# PBOETTCH JSON-SCHEMA-VALIDATOR
# ===========================================================================
RUN set -x && \
wget https://github.com/pboettch/json-schema-validator/archive/${pboettch_jsonschemavalidator_ver}.tar.gz && \
tar xvf ${pboettch_jsonschemavalidator_ver}.tar.gz && cd json-schema-validator*/ && mkdir build && cd build && \
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 .. && \
make -j${make_procs} && make install && \
cd ../.. && rm -rf * && \
set +x
# ===========================================================================
# GOOGLE TEST FRAMEWORK
# ===========================================================================
RUN set -x && \
wget https://github.com/google/googletest/archive/refs/tags/release-$(echo ${google_test_ver} | cut -c2-).tar.gz && \
tar xvf release-$(echo ${google_test_ver} | cut -c2-).tar.gz && cd googletest-release*/ && \
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 . && make -j${make_procs} install && \
cd .. && rm -rf * && \
set +x
# ---------------------------------------------------------------------------
# Builder entrypoint (cmake + make wrapper)
# ---------------------------------------------------------------------------
COPY deps/build.sh /var/build.sh
RUN chmod a+x /var/build.sh
ENTRYPOINT ["/var/build.sh"]
CMD []
# =============================================================================
# Stage: build (compile diametercodec project)
# =============================================================================
FROM deps AS build
ARG make_procs=4
ARG build_type=Release
COPY . /code
WORKDIR /code
RUN cmake -DCMAKE_BUILD_TYPE=${build_type} . && make -j${make_procs}
# =============================================================================
# Stage: unit-test (lightweight image for running tests)
# =============================================================================
FROM ubuntu:24.04 AS unit-test
ARG build_type=Release
COPY --from=build /code/build/${build_type}/bin/unit-test /opt/unit-test
ENTRYPOINT ["/opt/unit-test"]
CMD []