Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Docker Build Check

on:
push:
branches: [ "main", "master" ]
pull_request:
branches: [ "main", "master" ]

workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
# might need updating
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: . # Use the repository root as the build context
file: ./Dockerfile
push: false
tags: uvic-rover-build-test:latest
# think about disabling this if it is taking up too much space
cache-from: type=gha # Enable GitHub Actions cache for Docker layers
cache-to: type=gha,mode=max # Save cache for future runs

42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Use the official ROS Noetic base image (Ubuntu 20.04)
FROM ros:noetic-ros-base

LABEL maintainer="UVicRobotics <uvic.robotics@gmail.com>"

# Prevent interactive prompts during apt installations
ENV DEBIAN_FRONTEND=noninteractive

# Install essential tools and ROS dependencies listed in package.xml and CMakeLists.txt
# git is needed for rosdep to potentially fetch sources
# python3-pip might be needed for Python script dependencies not handled by rosdep
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
python3-pip \
ros-noetic-gps-common \
ros-noetic-robot-localization \
# Clean up apt cache to reduce image size
&& rm -rf /var/lib/apt/lists/*

# Create the catkin workspace directory
RUN mkdir -p /catkin_ws/src
WORKDIR /catkin_ws

# Copy the entire ROS package source code into the workspace's src directory
# Assumes the Dockerfile is located at the root of your uvic_rover package directory
COPY . src/uvic_rover/

RUN rosdep update

# Install dependencies listed in package.xml for all packages in the src directory
# --from-paths specifies where to find package.xml files
# --ignore-src prevents reinstalling packages already present in the src directory
# -r continues even if some dependencies fail (useful in CI, but check logs)
# -y confirms installations automatically
RUN rosdep install --from-paths src --ignore-src -r -y

# Build the catkin workspace
# Source the main ROS setup file before running catkin_make
RUN /bin/bash -c "source /opt/ros/noetic/setup.bash && catkin_make"

CMD ["/bin/bash", "-c", "source /catkin_ws/devel/setup.bash && bash"]

23 changes: 23 additions & 0 deletions docs/dev.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Docker instructions

1. Build the Docker image using a command like:
```bash
docker build -t uvic_rover_image .
```

2. Run the container interactively:

```bash
docker run -v $(pwd):/catkin_ws/src/ ... my_image
```

run this at the top of the repo. Mount the uvic_repo (pwd) into a catkin_ws/src (ros package)

3. Build packages

Inside catkin_ws

```bash
catkin_make
source devel/setup.bash
```