Skip to content

Commit fa237f1

Browse files
Add dev container configuration for GitHub Codespaces (#4193)
1 parent 969a961 commit fa237f1

File tree

3 files changed

+111
-0
lines changed

3 files changed

+111
-0
lines changed

.devcontainer/devcontainer.json

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "Quickwit",
3+
"image": "mcr.microsoft.com/devcontainers/rust:latest",
4+
"customizations": {
5+
"codespaces": {
6+
"openFiles": [
7+
"CONTRIBUTING.md"
8+
]
9+
},
10+
"vscode": {
11+
"extensions": [
12+
"rust-lang.rust-analyzer"
13+
]
14+
}
15+
},
16+
"hostRequirements": {
17+
"cpus": 4,
18+
"memory": "16gb"
19+
},
20+
"runArgs": [
21+
"--init"
22+
],
23+
"mounts": [
24+
{
25+
"source": "/var/run/docker.sock",
26+
"target": "/var/run/docker.sock",
27+
"type": "bind"
28+
}
29+
],
30+
"features": {
31+
"docker-from-docker": {
32+
"version": "latest",
33+
"moby": true
34+
},
35+
"ghcr.io/devcontainers/features/node:1": {
36+
"version": "18"
37+
},
38+
"ghcr.io/devcontainers/features/aws-cli:1": {},
39+
"ghcr.io/devcontainers-contrib/features/protoc:1": {}
40+
},
41+
"postCreateCommand": ".devcontainer/post-create.sh"
42+
}

.devcontainer/post-create.sh

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
3+
# Define success and error color codes
4+
SUCCESS_COLOR="\e[32m"
5+
ERROR_COLOR="\e[31m"
6+
RESET_COLOR="\e[0m"
7+
8+
# Define success tracking variables
9+
rustupToolchainNightlyInstalled=false
10+
cmakeInstalled=false
11+
12+
13+
# Define installation functions
14+
15+
#Installing manually for now until we figure out why "ghcr.io/devcontainers-community/features/cmake": {} is not working
16+
install_cmake() {
17+
echo -e "Installing CMake..."
18+
sudo apt-get update
19+
sudo apt-get install -y cmake > /dev/null 2>&1
20+
if [[ "$(cmake --version)" =~ "cmake version" ]]; then
21+
echo -e "${SUCCESS_COLOR}CMake installed successfully.${RESET_COLOR}"
22+
cmakeInstalled=true
23+
else
24+
echo -e "${ERROR_COLOR}CMake installation failed. Please install it manually.${RESET_COLOR}"
25+
fi
26+
}
27+
28+
install_rustup_toolchain_nightly() {
29+
echo -e "Installing Rustup nightly toolchain..."
30+
rustup toolchain install nightly > /dev/null 2>&1
31+
rustup component add rustfmt --toolchain nightly > /dev/null 2>&1
32+
if [[ "$(rustup toolchain list)" =~ "nightly" && "$(rustup component list --toolchain nightly | grep rustfmt)" =~ "installed" ]]; then
33+
echo -e "${SUCCESS_COLOR}Rustup nightly toolchain and rustfmt installed successfully.${RESET_COLOR}"
34+
rustupToolchainNightlyInstalled=true
35+
else
36+
echo -e "${ERROR_COLOR}Rustup nightly toolchain and/or rustfmt installation failed. Please install them manually.${RESET_COLOR}"
37+
fi
38+
}
39+
40+
# Install tools
41+
install_cmake
42+
install_rustup_toolchain_nightly
43+
44+
# Copy our custom welcome message to replace the default github welcome message
45+
sudo cp .devcontainer/welcome.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt
46+
47+
48+
# Check the success tracking variables
49+
if $rustupToolchainNightlyInstalled && $cmakeInstalled; then
50+
echo -e "${SUCCESS_COLOR}All tools installed successfully.${RESET_COLOR}"
51+
else
52+
echo -e "${ERROR_COLOR}One or more tools failed to install. Please check the output for errors and install the failed tools manually.${RESET_COLOR}"
53+
fi

.devcontainer/welcome.txt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
👋 Welcome to the project!
2+
All the necessary tools have already been installed for you 🎉.
3+
You can go ahead and start hacking! Happy coding💻.
4+
5+
Here are some useful commands you can run:
6+
7+
🔧 `make test-all` - starts necessary Docker services and runs all tests.
8+
🔧 `make -k test-all docker-compose-down` - the same as above, but tears down the Docker services after running all the tests.
9+
🔧 `make fmt` - runs formatter, this command requires the nightly toolchain to be installed by running `rustup toolchain install nightly`.
10+
🔧 `make fix` - runs formatter and clippy checks.
11+
🔧 `make typos` - runs the spellcheck tool over the codebase. (Install by running `cargo install typos`)
12+
🔧 `make build-docs` - builds docs.
13+
🔧 `make docker-compose-up` - starts Docker services.
14+
🔧 `make docker-compose-down` - stops Docker services.
15+
🔧 `make docker-compose-logs` - shows Docker logs.
16+

0 commit comments

Comments
 (0)