Skip to content

Commit

Permalink
Merge pull request #19 from traclabs/feature/consolidate_single_docke…
Browse files Browse the repository at this point in the history
…rfile

Feature/consolidate single dockerfile
  • Loading branch information
ana-GT authored Mar 6, 2024
2 parents 9e46fd3 + bfdb482 commit a889bfc
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 207 deletions.
173 changes: 173 additions & 0 deletions brash.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
################################################
# Build ros-base #
# (ROS2 image with default packages) #
################################################
FROM osrf/ros:humble-desktop AS ros-base
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
# Needed for OpenGL fix for Rviz to display
&& apt-get install -y software-properties-common \
&& add-apt-repository -y ppa:kisak/kisak-mesa \
&& apt update \
&& apt -y upgrade

RUN apt-get install -y \
python3-pip \
libnlopt-dev \
libnlopt-cxx-dev \
ros-humble-xacro \
ros-humble-joint-state-publisher \
ros-humble-srdfdom \
ros-humble-rqt*

RUN pip3 install cfdp

# Switch to bash shell
SHELL ["/bin/bash", "-c"]

# Create a brash user
ENV USERNAME=brash_user
ENV HOME_DIR=/home/${USERNAME}
ENV CODE_DIR=/code

# Dev container arguments
ARG USER_UID=1000
ARG USER_GID=${USER_UID}

# Create new user and home directory
RUN groupadd --gid ${USER_GID} ${USERNAME} \
&& useradd --uid ${USER_UID} --gid ${USER_GID} --create-home ${USERNAME} \
&& echo ${USERNAME} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USERNAME} \
&& chmod 0440 /etc/sudoers.d/${USERNAME} \
&& mkdir -p ${CODE_DIR} \
&& chown -R ${USER_UID}:${USER_GID} ${CODE_DIR}

USER ${USERNAME}
WORKDIR ${CODE_DIR}

################################################
# Build rosgsw-dev #
################################################

FROM ros-base AS rosgsw-dev
ENV DEBIAN_FRONTEND=noninteractive

RUN sudo apt-get install -y \
libnlopt-dev \
libnlopt-cxx-dev \
ros-humble-xacro \
ros-humble-joint-state-publisher \
ros-humble-srdfdom \
ros-humble-joint-state-publisher-gui \
ros-humble-geometric-shapes \
ros-humble-rqt-robot-steering \
ros-humble-rqt* \
libdwarf-dev \
libelf-dev \
libsqlite3-dev \
sqlitebrowser

# Set up sourcing
COPY --chown=${USERNAME}:${USERNAME} config/rosgsw_entrypoint.sh ${CODE_DIR}/entrypoint.sh
RUN echo 'source ${CODE_DIR}/entrypoint.sh' >> ~/.bashrc

# Get ready with brash workspace
RUN mkdir -p ${CODE_DIR}/brash
WORKDIR ${CODE_DIR}/brash

################################################
# Build rosfsw-dev #
################################################

FROM rosgsw-dev AS rosfsw-dev
ENV DEBIAN_FRONTEND=noninteractive

RUN sudo apt-get install -y \
ros-humble-controller-interface \
ros-humble-realtime-tools \
ros-humble-control-toolbox \
ros-humble-geometric-shapes \
ros-humble-controller-manager \
ros-humble-joint-trajectory-controller \
ros-humble-rqt* \
ignition-fortress \
ros-humble-ros-gz-sim \
ros-humble-ros-gz-bridge \
ros-humble-robot-localization \
ros-humble-interactive-marker-twist-server \
ros-humble-twist-mux \
ros-humble-joy-linux \
ros-humble-imu-tools \
ros-humble-ign-ros2-control \
ros-humble-joint-state-broadcaster \
ros-humble-diff-drive-controller

# Build a rover_ws into container
WORKDIR ${CODE_DIR}
RUN mkdir -p ${CODE_DIR}/rover_ws
WORKDIR ${CODE_DIR}/rover_ws

# Copy rover repos and robot config file required
COPY --chown=${USERNAME}:${USERNAME} ./config/rover.repos rover.repos
COPY --chown=${USERNAME}:${USERNAME} ./config/robot.yaml robot.yaml
RUN mkdir src && vcs import src < rover.repos

# Build the rover workspace
RUN source /opt/ros/humble/setup.bash && \
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release

# Set up sourcing
COPY --chown=${USERNAME}:${USERNAME} ./config/rosfsw_entrypoint.sh ${CODE_DIR}/entrypoint.sh
RUN echo 'source ${CODE_DIR}/entrypoint.sh' >> ~/.bashrc


# Source from rover_ws
WORKDIR ${CODE_DIR}/brash



##################################################
# Build rosgsw (Production)
##################################################
FROM rosgsw-dev AS rosgsw

# Copy brash=
COPY --chown=${USERNAME}:${USERNAME} brash ${CODE_DIR}/brash

# Build the brash workspace
WORKDIR ${CODE_DIR}/brash
RUN source /opt/ros/humble/setup.bash && \
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release

# Build juicer
#COPY --chown=${USERNAME}:${USERNAME} juicer ${CODE_DIR}/juicer
#WORKDIR ${CODE_DIR}/juicer
#RUN make

# Set workspace
WORKDIR ${CODE_DIR}/brash



##################################################
# Build rosfsw (Production)
##################################################
FROM rosfsw-dev AS rosfsw

# Copy brash
COPY --chown=${USERNAME}:${USERNAME} brash ${CODE_DIR}/brash

# Build the brash workspace
WORKDIR ${CODE_DIR}/brash
RUN source ${CODE_DIR}/rover_ws/install/setup.bash && \
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release

# Build juicer
#COPY --chown=${USERNAME}:${USERNAME} juicer ${CODE_DIR}/juicer
#WORKDIR ${CODE_DIR}/juicer
#RUN make

# Set workspace
WORKDIR ${CODE_DIR}/brash

9 changes: 3 additions & 6 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:
build:
# NOTE: Actual build process must be executed discretely for dev mounts
context: .
dockerfile: rosgsw.Dockerfile
dockerfile: brash.Dockerfile
target: rosgsw-dev
volumes:
- "./brash:/code/brash"
Expand All @@ -31,7 +31,7 @@ services:
image: "rosfsw-dev"
build:
context: .
dockerfile: rosfsw.Dockerfile
dockerfile: brash.Dockerfile
target: rosfsw-dev
volumes:
- "./brash:/code/brash"
Expand All @@ -40,10 +40,7 @@ services:
extends:
file: docker-compose-prod.yml
service: novnc
ros_base:
extends:
file: docker-compose-prod.yml
service: ros_base

# NOTE: networks apparently can't be imported from related file?
networks:
spaceip:
Expand Down
13 changes: 2 additions & 11 deletions docker-compose-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ services:
ipv4_address: 10.5.0.2
build:
context: .
dockerfile: rosgsw.Dockerfile
dockerfile: brash.Dockerfile
target: rosgsw
args:
- USER_UID=${UID:-1000}
Expand All @@ -45,7 +45,7 @@ services:
ipv4_address: 10.5.0.4
build:
context: .
dockerfile: rosfsw.Dockerfile
dockerfile: brash.Dockerfile
target: rosfsw
args:
- USER_UID=${UID:-1000}
Expand All @@ -62,15 +62,6 @@ services:
spaceip:
ipv4_address: 10.5.0.5

ros_base:
image: "ros-base"
build:
context: .
dockerfile: ros_base.Dockerfile
target: ros-base
args:
- USER_UID=${UID:-1000}

networks:
spaceip:
driver: bridge
Expand Down
44 changes: 0 additions & 44 deletions ros_base.Dockerfile

This file was deleted.

65 changes: 0 additions & 65 deletions rosfsw.Dockerfile

This file was deleted.

46 changes: 0 additions & 46 deletions rosgsw.Dockerfile

This file was deleted.

Loading

0 comments on commit a889bfc

Please sign in to comment.