Integrating GitHub Codespaces with FRC

Robotics software development in your browser

2020-09-10 github codespaces

I was recently accepted into the GitHub Codespaces beta test program. After reading through the documentation, I wanted to find a good use for this new tool, and decided to try it out on the largest open source project I am currently involved with. At Raider Robotics (@frc5024), we maintain a fairly large robotics software library called Lib5K. The goal of this library is to provide an easy-to-use framework for new programmers to use when writing control systems code. As this library has become more complex, we have recently forked it into its own GitHub repository, and completely reworked our dependency system to match that of any other large OSS project. I figured that setting this repository up to use Codespaces might make it easier for other developers at Raider Robotics to make small changes to the library without needing to pull in the nearly 5GB of dependencies needed just to compile the codebase.

I am quite impressed at how easy it is to set up a Codespace environment. All you need to do is, load a pre-made docker image, and write some JSON to configure the environment. I decided to write a custom Dockerfile that extends the base image.


RUN apt update -y
RUN apt install sudo -y

# Install needed packages
RUN sudo apt install -y python3 python3-pip
RUN sudo apt install -y curl wget
RUN sudo apt install -y zip unzip

# Install sdkman
RUN curl -s "" | bash

# Install java
RUN bash -c "source /root/.sdkman/bin/ && sdk install java 11.0.8-open"

# Install gradle
RUN bash -c "source /root/.sdkman/bin/ && sdk install gradle"

RUN echo "source /root/.sdkman/bin/" >> /root/.bashrc

# Install WPILib
RUN wget -O wpilib.tar.gz
RUN mkdir -p /root/wpilib/2020
RUN tar -zxvf wpilib.tar.gz -C /root/wpilib/2020

All that is being done in this container is:

  • Installing Python
  • Installing sdkman
  • Installing OpenJDK 11
  • Installing Gradle
  • Installing WPILib

In the world of FRC development, almost all codebases depend on a library and toolset called WPILib. The tar file that is downloaded contains a copy of the library, all JNI libraries depended on by WPILib itself, some extra tooling, and a custom JVM built specifically to run on the NI RoboRIO.

With this docker container, all we need to do is tell GitHub how to set up a Codespace for the repo. This is done by placing a file in .devcontainer/devcontainer.json:

// .devcontainer/devcontainer.json
    // Name of the environment
    "name":"General FRC Development",

    // Set the Docker image to use
    // I will explain this below

    // Set any default VSCode settings here
    "settings": {

    // Tell VSCode where to find the workspace directory
    "workspaceMount": "source=${localWorkspaceFolder},target=/root/workspace,type=bind,consistency=cached",
    "workspaceFolder": "/root/workspace",

    // Allow the host and container docker daemons to communicate
    "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker-host.sock,type=bind" ],

    // Any extensions you want can go here
    "extensions": [
        // Needed extensions for using WPILib

        // The WPILib extension itself

Notice the line "image":"ewpratten/frc_devcontainer:2020.3.2",. This is telling VSCode and Codespaces to pull a docker image from my docker hub account. Instead of making Codespaces build a docker image for itself when it loads, I have pre-built the image, and published it here. The reason for this is quite simple. Codespaces will flat out crash if it tries to build my dockerfile due to WPILib just being too big.

With a minimal amount of work, I got everything needed to develop and test FRC robotics code running in the browser via Codespaces.

Launching Codespaces from a GitHub repository

Editing code in the browser

Thank you for reading this post. If you enjoyed the content, and want to let me know, or want to ask any questions, please contact me via one of the methods listed here. If you would like to be notified about future posts, feel free to load my rss feed into your favorite feed reader, or follow me on Twitter for notifications about my work and future posts.

If you have the time to read some more, I recommend checking out one of the following posts:

Tunneling a printer from a home network to a VPN
I use a self-hosted VPN to access all my devices at all times, and to deal with my school's aggressive firewall. This post explains the process I use for exposing my home printer to the VPN.
2020 Wrap-Up
2020 has been my most productive year so far in terms of software development. This post looks back at the year
How I have tweaked my Minecraft client to be 'just right'
Over the past 10 years, I have been building the perfect Minecraft experience for myself. This post shares the collection of mods I run, and why I use them.

Made with ♥ by Evan Pratten | RSS | API Status