-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
110 lines (85 loc) · 2.72 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
# ==========
# Base Stage
# ==========
FROM ros:melodic-ros-core as base_stage
ARG PKG_NAME
ENV PKG_NAME=${PKG_NAME}
LABEL maintainer="M Kusold <michelle.kusold@freshconsulting.com>" description="Ros Intro"
SHELL ["/bin/bash","-c"]
ENV CATKIN_WS=/root/catkin_ws
# updating external dependencies list
RUN apt-get update && apt-get install --no-install-recommends -y \
build-essential \
python-rosdep \
python-pip
# update pip
RUN pip install --upgrade pip
# bootstrap rosdep
RUN rosdep init && \
rosdep update --rosdistro $ROS_DISTRO
# ===========
# Copy Stage
# ===========
FROM base_stage as copy_stage
# Create local catkin workspace
WORKDIR $CATKIN_WS/src
RUN mkdir -p "$PKG_NAME"
# install custom package
COPY . ./$PKG_NAME
# setting the working directory that's most useful for the other stages
WORKDIR $CATKIN_WS
# =========
# Dev Stage
# =========
FROM copy_stage as dev_stage
RUN apt-get update && apt-get install -y \
# CLI tools
tmux \
nano \
# linting and testing
python-autopep8 \
python-coverage \
python-mock \
# visualization tools
ros-${ROS_DISTRO}-turtlesim \
ros-${ROS_DISTRO}-rqt-graph \
ros-${ROS_DISTRO}-rviz
# Initialize local catkin workspace
RUN source /opt/ros/${ROS_DISTRO}/setup.bash \
# Update apt-get because its cache is always cleared after installs to keep image size down
&& apt-get update \
# Install dependencies
&& rosdep update \
&& rosdep install -y --from-paths . --ignore-src -r --rosdistro ${ROS_DISTRO} \
# Build catkin workspace
&& catkin_make
RUN echo "source $CATKIN_WS/devel/setup.bash \
&& cd $CATKIN_WS/src/$PKG_NAME" >> ~/.bashrc
# by default hold dev container open so you can connect to it
CMD ["bash"]
# ================
# Build Stage
# ================
FROM dev_stage as build_stage
RUN source /opt/ros/${ROS_DISTRO}/setup.bash \
&& catkin_make install
# ================
# Production Stage
# ================
FROM base_stage as prod_stage
ENV PROD_WS=~/${PKG_NAME}
ENV PROD_WS_INSTALL=${PROD_WS}/install
WORKDIR $PROD_WS_INSTALL
# grabbing the built ROS packages from the build stage
COPY --from=build_stage $CATKIN_WS/install ${PROD_WS_INSTALL}
ENV CATKIN_BUILT_PKGS=${PROD_WS_INSTALL}/share
# Updating the ROS external dependency management system
RUN source /opt/ros/${ROS_DISTRO}/setup.bash \
# Update apt-get because its cache is always cleared after installs to keep image size down
&& apt-get update \
# Install dependencies
&& rosdep update \
&& rosdep install -y --from-paths $PROD_WS_INSTALL --ignore-src -r --rosdistro ${ROS_DISTRO} --as-root apt:false
WORKDIR $PROD_WS
RUN echo "source $PROD_WS_INSTALL/setup.bash" >> ~/.bashrc
ENTRYPOINT source ${PROD_WS_INSTALL}/setup.bash && roslaunch ${PKG_NAME}_bringup ${PKG_NAME}_bringup.launch