1 # Using Development Containers for development and testing
3 You can set up a development environment for this project using [Development Containers](https://containers.dev/), aka devcontainers.
5 There are different ways of working with devcontainers. Some are automated and integrated in IDE applications, while others are more manual and require CLI tools. This guide will use [Visual Studio Code](https://code.visualstudio.com) and assumes that it's installed already.
7 Be aware that the containers will take significant space in your hard drive, in the region of 6GB.
11 You will need Git to clone (download) the code repository and push changes. How to install Git will depend on your operating system.
13 ### Ubuntu 24.04 LTS, Debian 13 (Trixie)
17 sudo apt-get install git-core
28 For macOS, you will need [Xcode Command Line Tools](https://mac.install.guide/commandlinetools/); macOS 14 (Sonoma) or later; and some familiarity with Unix development via the Terminal.
32 You can install Git using [WinGet](https://learn.microsoft.com/en-gb/windows/package-manager/winget/):
35 winget install --id Git.Git -e --source winget
38 Alternatively, see [other install options](https://git-scm.com/install/windows).
42 You will need to install Docker in order to run devcontainers. Again, the methods will depend on your operating system.
44 In general: if you get an error about not having permission to use Docker, you may need to add your user to the `docker` group. The details vary, but often this is a case of running the following command:
47 sudo usermod --append --group docker $USERNAME
50 Substitute `$USERNAME` with your actual username in the command above. After that, reboot your computer to ensure that this change takes effect.
54 1. Use Docker Desktop via [docker.com Download](https://www.docker.com/products/docker-desktop/).
56 2. You have to enable git symlinks before cloning the repository.
57 This repository uses symbolic links that are not enabled by default on Windows git. To enable them, [turn on Developer Mode](https://windowsreport.com/windows-11-developer-mode/) on Windows and run `git config --global core.symlinks true` to enable symlinks in Git. See [this StackOverflow question](https://stackoverflow.com/questions/5917249/git-symbolic-links-in-windows) for more information.
61 - Use Docker Desktop via [docker.com Download](https://www.docker.com/products/docker-desktop/).
62 - Or [Homebrew](https://formulae.brew.sh/cask/docker).
66 Use [Docker Engine](https://docs.docker.com/engine/install/ubuntu/) with the [docker-compose-plugin](https://docs.docker.com/compose/install/linux/)
68 ## Clone the repository
70 The repository is reasonably large (~560MB) and it's unlikely that you'll need the full history. Therefore you can probably do with a shallow clone (~100MB):
72 git clone --depth=1 https://github.com/openstreetmap/openstreetmap-website.git
75 If you want to add in the full history later on, perhaps to run `git blame` or `git log`, run `git fetch --unshallow`.
78 > To download the full history from the start, run:
80 > git clone https://github.com/openstreetmap/openstreetmap-website.git
83 ## Install Dev Containers extension
85 Start by opening the project with VS Code. Within it, you will need to install the extension _Dev Containers_, which can be done from the _Extensions_ section, reachable via the sidebar icons. Or VS Code may show a popup recommending this extension, with a button to install it directly.
87 
89 ## Open the project in a container
91 If everything is correct, this should make a few new commands available to you within VS Code. Find and run the command "Dev Containers: Reopen in Container".
93 
95 The first time you do this, it will go into a bit of a process. It will create the devcontainer, pull the Docker images, install the dependencies, etc. Go drink some water while this runs.
97 
99 Eventually this will present you with a development environment ready to go. In subsequent occasions this should be much faster.
103 If everything went well, you are done! For example, now you can open a shell in this environment using the VS Studio command "Create New Terminal (With Profile)":
105 
107 From this terminal, you can run the test suite with `bundle exec rails test:all`:
109 
111 Hopefully it should be all green? 🤞 You can also start a development server with `bundle exec rails s`:
113 
115 It will take a moment to start, after which you will be able to take a browser to http://localhost:3000 and visit your own local version of the site.
117 ## Other useful configuration
119 See [`CONFIGURE.md`](CONFIGURE.md) for information on how to manage users and enable OAuth for iD, JOSM etc.
123 VS Code is not the only way to work with devcontainers. Other options include:
125 - [RubyMine](https://www.jetbrains.com/help/ruby/start-dev-container-inside-ide.html): another popular environment to work with Ruby.
126 - [DevPod](https://devpod.sh): a CLI tool to work with devcontainers.
127 - [VSCodium](https://vscodium.com): a Free/Libre alternative to VS Code.
128 - [GitHub Codespaces](https://github.com/codespaces): GitHub's hosted IDE.
132 ### `‘ruby’: No such file or directory`
134 In some cases Ruby may not install correctly. If you see this message, run these two commands:
141 This has been observed particularly when using RubyMine.