-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
170 lines (119 loc) · 4.43 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# ==========
# Base image
# ==========
FROM ubuntu:22.04 AS base
ARG DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && \
apt-get install -y \
build-essential \
cmake \
libgoogle-glog-dev \
libgtest-dev \
libyaml-cpp-dev && \
apt-get clean
# Install Crow dependencies
RUN apt-get update && \
apt-get install -y \
libasio-dev \
zlib1g-dev &&\
apt-get clean
# Install Crow (C++ REST/WebSocket server) and util_caching
# `ADD` downloads the Crow and util_caching debian releases and adds them to the docker image
# This "bloats" the image. But otherwise, we'd have to installing wget and ca-certificates
# temporarily to download and install the package in one docker layer…
ADD https://github.com/CrowCpp/Crow/releases/download/v1.2.0/Crow-1.2.0-Linux.deb /tmp/debfiles/
ADD https://github.com/KIT-MRT/util_caching/releases/latest/download/libutil-caching-dev.deb /tmp/debfiles/
# Install Crow and util_caching from release debian package
RUN dpkg -i /tmp/debfiles/*.deb && \
rm -rf /tmp/debfiles
# ===========
# Development
# ===========
FROM base AS devel
RUN useradd --create-home --uid 1000 blinky
USER blinky
WORKDIR /home/blinky/
# ==========
# Unit tests
# ==========
FROM base AS unit_test
COPY CMakeLists.txt /tmp/arbitration_graphs/
COPY LICENSE /tmp/arbitration_graphs/
COPY README.md /tmp/arbitration_graphs/
COPY cmake /tmp/arbitration_graphs/cmake
COPY gui /tmp/arbitration_graphs/gui
COPY include /tmp/arbitration_graphs/include
COPY test /tmp/arbitration_graphs/test
COPY version /tmp/arbitration_graphs/version
WORKDIR /tmp/arbitration_graphs/build
RUN cmake -DBUILD_TESTS=true .. && \
cmake --build . -j9
# Run unit tests
CMD ["cmake", "--build", ".", "--target", "test"]
# =======
# Release
# =======
FROM base AS release
COPY CMakeLists.txt /tmp/arbitration_graphs/
COPY LICENSE /tmp/arbitration_graphs/
COPY README.md /tmp/arbitration_graphs/
COPY version /tmp/arbitration_graphs/
COPY cmake /tmp/arbitration_graphs/cmake
COPY gui /tmp/arbitration_graphs/gui
COPY include /tmp/arbitration_graphs/include
WORKDIR /tmp/arbitration_graphs/build
RUN cmake .. && \
cmake --build . && \
cmake --build . --target package && \
mv packages /release && \
rm -rf /tmp/arbitration_graphs
# =============
# Release tests
# =============
FROM base AS release_test_core
ARG RELEASE_DOWNLOAD_URL=https://github.com/KIT-MRT/arbitration_graphs/releases/latest/download/
# This downloads the latest arbitration_graph debian release and adds it to the docker image
# This "bloats" the image. But otherwise, we'd have to installing wget and ca-certificates
# temporarily to download and install the package in one docker layer…
ADD ${RELEASE_DOWNLOAD_URL}/libarbitration-graphs-core-dev.deb /tmp/debfiles/
# Install arbitration_graphs core library from release debian package
RUN dpkg -i /tmp/debfiles/*.deb && \
rm -rf /tmp/debfiles
COPY test /tmp/arbitration_graphs_test
WORKDIR /tmp/arbitration_graphs_test/build
RUN cmake .. && \
cmake --build . -j9
CMD ["cmake", "--build", ".", "--target", "test"]
FROM base AS release_test_gui
ARG RELEASE_DOWNLOAD_URL=https://github.com/KIT-MRT/arbitration_graphs/releases/latest/download/
# This downloads the latest arbitration_graph debian release and adds it to the docker image
# This "bloats" the image. But otherwise, we'd have to installing wget and ca-certificates
# temporarily to download and install the package in one docker layer…
ADD ${RELEASE_DOWNLOAD_URL}/libarbitration-graphs-core-dev.deb /tmp/debfiles/
ADD ${RELEASE_DOWNLOAD_URL}/libarbitration-graphs-gui-dev.deb /tmp/debfiles/
# Install arbitration_graphs gui from release debian package
RUN dpkg -i /tmp/debfiles/*.deb && \
rm -rf /tmp/debfiles
COPY gui/test /tmp/arbitration_graphs_test
WORKDIR /tmp/arbitration_graphs_test/build
RUN cmake .. && \
cmake --build . -j9
CMD ["cmake", "--build", ".", "--target", "test"]
# =======
# Install
# =======
FROM base AS install
COPY CMakeLists.txt /tmp/arbitration_graphs/
COPY LICENSE /tmp/arbitration_graphs/
COPY README.md /tmp/arbitration_graphs/
COPY version /tmp/arbitration_graphs/
COPY cmake /tmp/arbitration_graphs/cmake
COPY gui /tmp/arbitration_graphs/gui
COPY include /tmp/arbitration_graphs/include
COPY test /tmp/arbitration_graphs/test
WORKDIR /tmp/arbitration_graphs/build
RUN cmake .. && \
cmake --build . && \
cmake --install . && \
rm -rf /tmp/arbitration_graphs