In an attempt to create a standard development environment to reduce setup time and debugging the PSU Power Lab has adopted the use of docker. If you are unfamiliar with docker and containers in general I highly recommend watching docker's get started. Following the tutorials you will know docker works as well as the general setup of a dockerfile for your development environment.
Our dockerfile consists of all project dependancies required to run each of our projects. This means that the container takes some time to install, but once it is installed each project can seemlessly be cloned and worked on within.
- Download and install docker on your machine following the instructions specific to your Operating System. see the get started link above
- Clone this repository to your machine
- Change directory to the docker-tutorial folder
- Build the Dockerfile.buster and wait for the process to finish
- Run the docker image as -id interactive and detached so it is running in the background
git clone https://github.com/PortlandStatePowerLab/docker-tutorial
cd docker-tutorial
docker build --file Dockerfile.buster --tag psu-dev .
docker run -id psu-devI have found that my machine will delete images after a system update. This is actually a common issue that will hopefully be fixed soon. If you have room on your machine, approximatly 3 GB, I recommend saving the image to a tar file so that you can always reload the image if something happens.
cd docker-tutorial
docker save --output psu-dev.tar psu-dev
docker load < psu-dev.tarNow that we have a docker container running we can set up our editor to attach to it and program from our local machine as if it was the container. Each IDE or Editor has its own setup, but we will show how to setup using Visual Studio Code as it is cross-platform and fairly straight forward.
Download VS Code from https://code.visualstudio.com/ and install according to your operating system.
Once VS Code is installed you will need a few extensions to make developing in your project much easier. This only lists C++ specific extensions, but you can find extensions for any language you are working in. The most important are Docker and Remote - Container as these are what allows VS Code to attach to a container and act as if your local machine is the container.
- C/C++
- C++ Helper
- CMake
- Docker
- Remote - Container
- Remote - SSH
The following link shows you how to simply connect to a container to start development. And off you go!