This repository has been archived by the owner on Feb 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(devcontainer): added devcontainer (#43)
- Loading branch information
Showing
5 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.dockerignore | ||
devcontainer.json | ||
docker-compose.yml | ||
Dockerfile | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FROM qmcgaw/rustdevcontainer:debian | ||
RUN rustup update nightly && rustup target add wasm32-unknown-unknown --toolchain nightly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Development container | ||
|
||
Development container that can be used with VSCode. | ||
|
||
It works on Linux, Windows and OSX. | ||
|
||
## Requirements | ||
|
||
- [VS code](https://code.visualstudio.com/download) installed | ||
- [VS code remote containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) installed | ||
- [Docker](https://www.docker.com/products/docker-desktop) installed and running | ||
- [Docker Compose](https://docs.docker.com/compose/install/) installed | ||
|
||
## Setup | ||
|
||
1. Create the following files on your host if you don't have them: | ||
|
||
```sh | ||
touch ~/.gitconfig ~/.zsh_history | ||
``` | ||
|
||
Note that the development container will create the empty directories `~/.docker`, `~/.ssh` and `~/.kube` if you don't have them. | ||
1. **For Docker on OSX or Windows without WSL**: ensure your home directory `~` is accessible by Docker. | ||
1. Open the command palette in Visual Studio Code (CTRL+SHIFT+P). | ||
1. Select `Remote-Containers: Open Folder in Container...` and choose the project directory. | ||
## Customization | ||
### Customize the image | ||
You can make changes to the [Dockerfile](Dockerfile) and then rebuild the image. For example, your Dockerfile could be: | ||
```Dockerfile | ||
FROM qmcgaw/rustdevcontainer | ||
RUN apk add curl | ||
``` | ||
To rebuild the image, either: | ||
- With VSCode through the command palette, select `Remote-Containers: Rebuild and reopen in container` | ||
- With a terminal, go to this directory and `docker-compose build` | ||
### Customize VS code settings | ||
You can customize **settings** and **extensions** in the [devcontainer.json](devcontainer.json) definition file. | ||
### Entrypoint script | ||
You can bind mount a shell script to `/root/.welcome.sh` to replace the [current welcome script](shell/.welcome.sh). | ||
### Publish a port | ||
To access a port from your host to your development container, publish a port in [docker-compose.yml](docker-compose.yml). You can also now do it directly with VSCode without restarting the container. | ||
### Run other services | ||
1. Modify [docker-compose.yml](docker-compose.yml) to launch other services at the same time as this development container, such as a test database: | ||
```yml | ||
database: | ||
image: postgres | ||
restart: always | ||
environment: | ||
POSTGRES_PASSWORD: password | ||
``` | ||
1. In [devcontainer.json](devcontainer.json), change the line `"runServices": ["vscode"],` to `"runServices": ["vscode", "database"],`. | ||
1. In the VS code command palette, rebuild the container. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"name": "project-dev", | ||
"dockerComposeFile": ["docker-compose.yml"], | ||
"service": "vscode", | ||
"runServices": ["vscode"], | ||
"shutdownAction": "stopCompose", | ||
"postCreateCommand": "~/.windows.sh", | ||
"workspaceFolder": "/workspace", | ||
// "overrideCommand": "", | ||
"extensions": [ | ||
"rust-lang.rust-analyzer", | ||
"tamasfe.even-better-toml", // for Cargo.toml | ||
"eamodio.gitlens", // IDE Git information | ||
"davidanson.vscode-markdownlint", | ||
"ms-azuretools.vscode-docker", // Docker integration and linting | ||
"shardulm94.trailing-spaces", // Show trailing spaces | ||
"Gruntfuggly.todo-tree", // Highlights TODO comments | ||
"bierner.emojisense", // Emoji sense for markdown | ||
"stkb.rewrap", // rewrap comments after n characters on one line | ||
"vscode-icons-team.vscode-icons", // Better file extension icons | ||
"github.vscode-pull-request-github", // Github interaction | ||
"redhat.vscode-yaml", // Kubernetes, Drone syntax highlighting | ||
"bajdzis.vscode-database", // Supports connections to mysql or postgres, over SSL, socked | ||
"IBM.output-colorizer", // Colorize your output/test logs | ||
// "mohsen1.prettify-json", // Prettify JSON data | ||
// "zxh404.vscode-proto3", // Supports Proto syntax | ||
// "jrebocho.vscode-random", // Generates random values | ||
// "alefragnani.Bookmarks", // Manage bookmarks | ||
// "quicktype.quicktype", // Paste JSON as code | ||
// "spikespaz.vscode-smoothtype", // smooth cursor animation | ||
], | ||
"settings": { | ||
"files.eol": "\n", | ||
"[rust]": { | ||
"editor.defaultFormatter": "rust-lang.rust-analyzer", | ||
"editor.formatOnSave": true | ||
}, | ||
"remote.extensionKind": { | ||
"ms-azuretools.vscode-docker": "workspace" | ||
}, | ||
"editor.codeActionsOnSaveTimeout": 3000, | ||
"rust-analyzer.serverPath": "/usr/local/bin/rust-analyzer" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
version: "3.7" | ||
|
||
services: | ||
vscode: | ||
build: . | ||
volumes: | ||
- ../:/workspace | ||
# Docker | ||
- ~/.docker:/root/.docker | ||
# Docker socket to access Docker server | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
# SSH directory for Linux, OSX and WSL | ||
# On Linux and OSX, a symlink /mnt/ssh <-> ~/.ssh is | ||
# created in the container. On Windows, files are copied | ||
# from /mnt/ssh to ~/.ssh to fix permissions. | ||
- ~/.ssh:/mnt/ssh | ||
# Shell history persistence | ||
- ~/.zsh_history:/root/.zsh_history | ||
# Git config | ||
- ~/.gitconfig:/root/.gitconfig | ||
# Kubernetes | ||
# - ~/.kube:/root/.kube | ||
environment: | ||
- TZ= | ||
# Needed for debugging | ||
# cap_add: | ||
# - SYS_PTRACE | ||
# security_opt: | ||
# - seccomp:unconfined | ||
entrypoint: zsh -c "while sleep 1000; do :; done" |