Skip to content

Commit

Permalink
Merge pull request #143 from moreal/devcontainer
Browse files Browse the repository at this point in the history
Introduce devcontainer
  • Loading branch information
dahlia authored Sep 28, 2024
2 parents 451def1 + 5126ffb commit 68fa8fb
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .devcontainer/bin/postAttachCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

set -e

# Run codegen
deno task -c src/deno.json codegen
deno task -c cli/deno.json codegen

# .bashrc doesn't work when creating a new container.
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
export PATH="$PATH:$HOME/.bun/bin"

echo
echo "INFO: Tool version"
echo "node: $(node -v)"
deno -v
echo "bun: $(bun -v)"
echo "pnpm: $(pnpm -v)"
echo
34 changes: 34 additions & 0 deletions .devcontainer/bin/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

set -e

export BUN_VERSION="v1.1.29"
export NODE_VERSION="20"
export NVM_VERSION="v0.40.0"
export PNPM_VERSION="9.11.0"

# Setup deno completions
mkdir -p /usr/local/etc/bash_completion.d/
deno completions bash > /usr/local/etc/bash_completion.d/deno.bash

cat << EOF >> ~/.bashrc
source /usr/local/etc/bash_completion.d/deno.bash
EOF

apt update
apt upgrade -y

apt install -y git curl unzip vim

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/$NVM_VERSION/install.sh | bash

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

nvm install "$NODE_VERSION"

corepack enable
corepack install -g "pnpm@$PNPM_VERSION"

curl -fsSL https://bun.sh/install | bash -s "bun-$BUN_VERSION"
17 changes: 17 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "Development Environment",
"image": "denoland/deno:ubuntu-1.46.3",
"postCreateCommand": ".devcontainer/bin/postCreateCommand.sh",
"postAttachCommand": ".devcontainer/bin/postAttachCommand.sh",
"customizations": {
"vscode": {
"extensions": [
"denoland.vscode-deno",
"redhat.vscode-yaml",
"streetsidesoftware.code-spell-checker"
]
}
}
}

0 comments on commit 68fa8fb

Please sign in to comment.