-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
133 lines (96 loc) · 3.09 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
ARG UBUNTU_VERSION=jammy
ARG FROM_IMAGE=ubuntu:$UBUNTU_VERSION
ARG OVERLAY_WS=/opt/rnz/overlay_ws
# ARG TEST_PATH=capra-ros-local-planner/capra-ros-local-planner/test
# MAKE SOME BASIC MODIFICATION TO THE BASE IMAGE
FROM $FROM_IMAGE AS dependencies_setter
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \
apt-get update \
&& apt-get install -y -q --no-install-recommends\
cmake \
curl \
python3-pip \
nano \
gnupg \
gdb \
sudo \
clang-tidy \
build-essential \
&& pip install -U autopep8 \
&& rm -rf /var/lib/apt/lists/*
ENV CMAKE_MAKE_PROGRAM=/usr/bin/make
ENV CMAKE_CXX_COMPILER=/usr/bin/g++
ENV RMW_IMPLEMENTATION=rmw_fastrtps_cpp
# MAKE THE DEVELOPER VERSION OF THE IMAGE
FROM dependencies_setter as developer
# Set timezone
ENV TZ=Europe/Copenhagen
ENV RMW_IMPLEMENTATION=rmw_fastrtps_cpp
ARG USERNAME=rnz
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME -s /bin/bash \
&& mkdir -p /home/$USERNAME/.vscode-server /home/$USERNAME/.vscode-server-insiders \
&& chown ${USER_UID}:${USER_GID} /home/$USERNAME/.vscode-server* \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
WORKDIR /home/$USERNAME
USER $USERNAME
ARG ROS_SETUP
ARG WORKSPACE
ARG OVERLAY_WS
# MULTI-STAGE FOR CACHING
FROM dependencies_setter AS cacher
# copy overlay source
ARG OVERLAY_WS
WORKDIR $OVERLAY_WS/src
# MULTI-STAGE FOR BUILDING DEPENDENCIES FROM SOURCE
FROM dependencies_setter AS prebuilder
ARG DEBIAN_FRONTEND=noninteractive
# install overlay dependencies
ARG OVERLAY_WS
WORKDIR $OVERLAY_WS
# install CI dependencies
RUN apt-get update && apt-get install -q -y --no-install-recommends \
ccache \
lcov \
&& mkdir src \
&& rm -rf /var/lib/apt/lists/*
# build overlay source
COPY --from=cacher $OVERLAY_WS ./
ARG OVERLAY_MIXINS="release ccache"
# BUILD CURRENT PROJECT WITH COLCON (CMAKE)
FROM dependencies_setter AS builder
ARG OVERLAY_WS
WORKDIR $OVERLAY_WS
RUN apt update \
&& apt install -y -q --no-install-recommends \
clang-tidy \
&& rm -rf /var/lib/apt/lists/*
COPY --from=prebuilder $OVERLAY_WS/ ./
COPY ./project_folder ./src/project_folder
RUN rm -rf ./src/project_folder/build
RUN mkdir $OVERLAY_WS/src/project_folder/build
RUN cd $OVERLAY_WS/src/project_folder/build && cmake .. && make
CMD ["tail", "-f", "/dev/null"]
# RUN ALL TESTS IN GTEST
FROM builder AS tester
ARG OVERLAY_WS
RUN cd $OVERLAY_WS/src/project_folder/build && ctest
WORKDIR $OVERLAY_WS/src/project_folder
# COPY ./run_tests.sh $OVERLAY_WS
# CMD ["./run_tests.sh"]
CMD ["tail", "-f", "/dev/null"]
# MULTI-STAGE FOR RUNNING
FROM dependencies_setter AS runner
ARG OVERLAY_WS
WORKDIR $OVERLAY_WS
# THIS SHOULD BE CHANGED FOR A INSTALLED FOLDER!!!!!!!!
COPY --from=builder $OVERLAY_WS/src/project_folder $OVERLAY_WS/src/project_folder
# RUN rm -rf $(find . -type d -name include)
ENV OVERLAY_WS $OVERLAY_WS
# RUN A APP FILE
COPY entrypoint.sh /entrypoint.sh
RUN chmod -x /entrypoint.sh
ENTRYPOINT ["tail", "-f", "/dev/null"]