2020-12-08 06:24:46 +00:00
# Development container
Development container that can be used with VSCode.
2024-10-10 08:33:33 +00:00
It works on Linux, Windows (WSL2) and OSX.
2020-12-08 06:24:46 +00:00
## Requirements
- [VS code ](https://code.visualstudio.com/download ) installed
2024-10-10 08:33:33 +00:00
- [VS code dev containers extension ](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers ) installed
2020-12-08 06:24:46 +00:00
- [Docker ](https://www.docker.com/products/docker-desktop ) installed and running
## Setup
2024-10-20 12:57:58 +00:00
1. Create the following files and directory on your host if you don't have them:
2023-05-29 15:57:09 +00:00
```sh
touch ~/.gitconfig ~/.zsh_history
2024-10-20 12:57:58 +00:00
mkdir -p ~/.ssh
2023-05-29 15:57:09 +00:00
```
2024-10-20 12:57:58 +00:00
1. **For Docker on OSX ** : ensure the project directory and your home directory `~` are accessible by Docker.
2020-12-08 06:24:46 +00:00
1. Open the command palette in Visual Studio Code (CTRL+SHIFT+P).
2024-10-20 12:57:58 +00:00
1. Select `Dev Containers: Open Folder in Container...` and choose the project directory.
2020-12-08 06:24:46 +00:00
## Customization
2024-10-20 12:57:58 +00:00
For any customization to take effect, you should "rebuild and reopen":
2020-12-08 06:24:46 +00:00
2024-10-10 08:33:33 +00:00
1. Open the command palette in Visual Studio Code (CTRL+SHIFT+P)
2024-10-20 12:57:58 +00:00
2. Select `Dev Containers: Rebuild Container`
2020-12-08 06:24:46 +00:00
2024-10-20 12:57:58 +00:00
Changes you can make are notably:
2020-12-08 06:24:46 +00:00
2024-10-10 08:33:33 +00:00
- Changes to the Docker image in [Dockerfile ](Dockerfile )
- Changes to VSCode **settings ** and **extensions ** in [devcontainer.json ](devcontainer.json ).
2024-10-20 12:57:58 +00:00
- Change the entrypoint script by adding a bind mount in [devcontainer.json ](devcontainer.json ) of a shell script to `/root/.welcome.sh` to replace the [current welcome script ](https://github.com/qdm12/godevcontainer/blob/master/shell/.welcome.sh ). For example:
2024-10-10 08:34:56 +00:00
```json
2024-10-20 12:57:58 +00:00
// Welcome script
2024-10-10 08:34:56 +00:00
{
"source": "/yourpath/.welcome.sh",
"target": "/root/.welcome.sh",
"type": "bind"
},
2020-12-08 06:24:46 +00:00
```
2024-10-20 12:57:58 +00:00
- More options are documented in the [devcontainer.json reference ](https://containers.dev/implementors/json_reference/ ).