Code for Life Community hub
Python DenRapid RouterCode for Life website
  • 💛Welcome
  • 📅Release Notes
  • âĪïļBecome a Contributor
  • ðŸŠīIndustry Experience
  • 🏆Wall of Fame
  • ðŸ“ĶRepositories and Packages
  • ðŸī󠁧ó Ēó Ĩó Ū󠁧ó ŋNational Curriculum alignment
  • ðŸī󠁧ó Ēó ģó Ģó īó ŋNational Curriculum alignment
  • â„đïļGlossary
  • COMMUNICATIONS
    • 📖Publications
  • 🗞ïļNewsletters
    • 🎊Spring 2025
    • 🌷Bett show 2025
    • 🎄December 2024
    • 🍁Autumn 2024
    • ðŸŒŧSummer 2024
    • 🐰Spring 2024
    • ❄ïļWinter 2024
    • 🎄December 2023
    • 🍁Autumn 2023
    • ðŸŒŧSummer 2023
    • 🌷Spring 2023
    • 🎄December 2022
    • 🍁Autumn 2022
    • ðŸŒŧSummer 2022
    • 🌷Spring 2022
    • 🎄December 2021
  • ðŸ§ĐNewsletter challenges
    • ðŸĪ–Ocado Robot Debugging Challenge!
  • ðŸĪ–Books of Robots
  • Community resource hub
    • ðŸ’ŧHow do Computers work?
    • 🔐Safety online: Passwords and Security
    • ðŸĪ–The World of Robotics
    • ðŸĶūCareers in technology
      • 📃Careers posters
      • ðŸ“―ïļCareer based videos
  • 🗚ïļLevel Maps 1‒50
  • Software Developer Guide
    • ðŸ’ŧDev Environment Setup
    • 🔝Code Promotion Strategy
    • ðŸ’ŋBack End
      • â„đïļOverview
      • ✍ïļCoding Patterns
      • 🧊Testing Strategy
    • ðŸ–ąïļFront End
      • â„đïļOverview
      • ✍ïļCoding Patterns
      • 🧊Testing Strategy
  • Links
    • Code Workspace
    • Visit our Site
Powered by GitBook
LogoLogo

Copyright Ocado Group 2025

On this page
  • 1. Install and set up Git
  • 2. Install Docker Engine
  • Windows
  • macOS
  • Linux
  • 3. Install VS Code
  • 4. Install the Dev Containers extension in VS Code
  • 5. Fork and clone the CFL workspace
  • 6. Change line endings (Windows only)
  • 7. Open the CFL workspace in a Dev Container
  • Known issues
  • 8. Set up your CFL workspace
  • 9. Enable source control
  • 10. Set up the repo's virtual environment
  • 11. Exiting the Dev Container

Was this helpful?

Export as PDF
  1. Software Developer Guide

Dev Environment Setup

Set up your dev environment with dev containers for VS Code.

PreviousLevel Maps 1‒50NextCode Promotion Strategy

Last updated 5 months ago

Was this helpful?

Code for Life (CFL) has set up their development environment within . In short, dev containers are containerised virtual machines that come preinstalled with all the software and tools necessary for you to develop.

A git submodule is synonymous with a git repository; a submodule is a repo that's nested within the workspace.

VS Code's dev containers allow us to setup your dev environment for you so you don't have to worry about doing it yourself. Furthermore, anytime we make a change to our dev environment, we will git-push the latest dev container to the workspace repo. Then, you can just simply git-pull the latest dev container and rebuild it.

Follow the below steps to setup the CFL workspace in a dev container.


1. Install and set up Git

Git is required to sync your local code changes with our online Git repos.

Follow Git's and .

git config --global user.name "John Doe"
git config --global user.email "john.doe@example.com"

2. Install Docker Engine

Docker Engine is required to build and run dev containers.

Note that Docker Desktop is an app built around Docker Engine that provides a user interface and additional tools. You only need Docker Engine.

If you're using an Ocado-issued laptop, DO NOT install Docker Desktop - it's licensed software requiring a paid subscription.

Windows

macOS

We recommend running the following commands.

# Install Docker Engine
brew install docker

# Install and start Colima
brew install colima
colima start

# Test docker is working
sudo docker -H <hostname> run hello-world

Linux


3. Install VS Code

Our dev containers are specifically defined to work within the VS Code IDE.


4. Install the Dev Containers extension in VS Code

Open the Extensions tab (Ctrl+Shift+X) in VS Code.

Search for the "Dev Containers" extension and install it.


5. Fork and clone the CFL workspace

git clone https://github.com/{username}/codeforlife-workspace.git


6. Change line endings (Windows only)

If you're using Windows as your OS, then you'll need to change the line endings in your cloned workspace before opening the dev container.

Open a Git Bash terminal in the directory of your cloned workspace.

Configure the workspace to use LF as the EOL control character.

git config core.eol lf

Remove all the files tracked by Git in the workspace.

git rm -rf --cached .

Re-download the files. They should now have LF endings.

git reset --hard HEAD

To confirm that the files have LF endings, open any file in the workspace in VS Code and look at the bottom right (in the toolbar). You should see "LF" (not "CRLF").

7. Open the CFL workspace in a Dev Container

In VS Code, open the command palette (Ctrl+Shift+P or go to View > Command Palette...).

Search for the command: ">Dev Containers: Open Workspace in Container..." and select it.

Make sure Docker Engine is running before working with dev containers.

Select the codeforlife.code-workspace file in your local codeforlife-workspace folder.

path/to/codeforlife-workspace/codeforlife.code-workspace

VS Code will now begin building your dev container. If you wish to see the output of the build as it is happening, click the following prompt in the bottom-right:

At some point, VS Code will reload the window so that it may re-open the code-workspace within the dev container.

The first time the container is built takes some time, as it needs to download its OS and the various software, tools and extensions required for development. The duration of the build will also depend on your internet speed and processing power.

First-time builds have been known to take around 10-15 minutes.

Luckily, this is a one-off; the build is cached and rebuilds will be significantly faster!

Known issues

If the build fails with an error message similar to:

=> ERROR resolve image config for docker.io/docker/dockerfile:1.4        31.5s
=> [auth] docker/dockerfile:pull token for registry-1.docker.io           0.0s
------
> resolve image config for docker.io/docker/dockerfile:1.4:
------

Run this command before opening/building the dev container.

docker pull docker.io/docker/dockerfile:1.4

Images or dependencies fail to install

If you get build errors stating that some images or dependencies failed to install, it could be due to any VPN / DDoS mitigation software you might have running on your machine or network. Try disabling those temporarily to see if it helps.


8. Set up your CFL workspace

To help you quickly fork and clone the many repos contained within our workspace, we've created a script that runs automatically when you start the workspace's dev container. You'll be prompted to sign into GitHub in VS Code's terminal window.

Follow the on-screen instructions in the terminal. Once you've successfully authenticated with GitHub, each repo within the workspace should be forked and cloned; the once empty folders should now be populated.


9. Enable source control

You many not need to do this step. If VS Code has disabled source control for the CFL repos you wish to develop for, you'll need to trust the repos within VS Code to enable source-control features like:

  • checking out branches

  • pulling, committing and pushing code changes.

With the workspace folder open in VS Code, open the Source Control tab (Ctrl+Shift+G).

Click "Manage Unsafe Repositories". Then, select the one or more CFL repos shown in the drop-down.


10. Set up the repo's virtual environment

This step is only needed if you are working on either the rapid-router or codeforlife-portal repo.

In a new terminal in VS Code, run the following command:

pipenv install --dev

This will install all the dependencies the repo requires for the code to run. Then, activate the virtual environment by running:

pipenv shell

Finally, to start working on the project locally, run:

./run

This script will:

  • run the project's database migrations,

  • collect the static files,

  • and start a Django server.

Once the script has finished running, you'll be able to run and view the project locally in your browser by going to localhost:8000.

Any backend changes you make to the code should automatically reload the Django server (a.k.a. hot reloading). HTML changes will also be visible instantly.

However, any JS or CSS changes will require you to manually close the server using Ctrl/Cmd + C and relaunch the run script so that the static files are re-collected.

Enjoy working on the project!

11. Exiting the Dev Container

There are a few different ways you can stop running your VS Code window in a dev container and run it on your local machine instead.

  • Close the VS Code window and open a new window.

  • Open a local folder in the existing VS Code window ([Ctrl+K Ctrl+O] or go to File > Open Folder...).

  • Reopen the current folder locally by either:

    1. Opening the command palette (Ctrl+Shift+P or go to View > Command Palette...) and typing ">Dev Containers: Reopen Folder Locally".

    2. Clicking the Dev Container toolbox in the bottom-left of your VS Code window and selecting Reopen Folder Locally.

  • Close the connection to the dev container by either:

    1. Opening the command palette (Ctrl+Shift+P or go to View > Command Palette...) and typing ">Remote: Close Remote Connection".

    2. Clicking the Dev Container toolbox in the bottom-left of your VS Code window and selecting Close Remote Connection.

to download and install Docker Engine's server and client binaries.

Alternatively, you can install .

Check the to find your Linux distro. If you're using Ubuntu, follow .

.

our (only the main branch) first and then, in a folder of your choosing on your local machine, clone your fork:

and Unix-like OS's (like Linux and macOS) use different end of line (EOL) to Windows. Linux distributions (like Ubuntu) use line feed (LF), which is control character "\n", while Windows uses carriage return and line feed (CRLF), which is control characters "\r\n". .

Fails to pull

While the workspace is open in VS Code you'll notice there are a few empty folders. These are the repos contained within the workspace, each of which will also need to be forked and cloned ().

ðŸ’ŧ
dev containers for VS Code
installation instructions
first-time setup instructions
Follow the steps
Docker Engine's client binaries
supported platforms
these steps
Install VS Code
Fork
workspace
Inside the dev container the OS is Ubuntu
control characters
See EOL table
docker/dockerfile
like how you forked and cloned the workspace
example terminal that's open in the "codeforlife-workspace" directory
Use the arrows on your keyboard and Enter to select an option
Dev Container: toolbox