Skip to content

Commit

Permalink
chore: add initial vscode devcontainer files (#6736)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikwilson authored May 9, 2023
1 parent 80f83cf commit 22eeec6
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .determined.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"folders": [
{
"path": "."
}
]
}
11 changes: 11 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### Steps for using a devcontainer (without Kubernetes)

0. Launch a cluster with the `det deploy` command.
1. Ensure that VSCode dev extensions are installed.
2. SSH to server instance and setup VSCode with remote SSH server.
3. Resize disk space on remote server if needed.
4. Setup github credentials and clone repository.
5. Stop the deployed server instance.
6. Open workspace file with VSCode connected to remote SSH server.
7. Use VSCode to build and launch devcontainer.
8. After remote server launches localhost:8080 should be available.
66 changes: 66 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/go
{
"name": "determined-backend-dev-go",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/go:0-1.20",
"features": {
"ghcr.io/guiyomh/features/golangci-lint:0": {},
"ghcr.io/devcontainers/features/python:1": {},
"ghcr.io/devcontainers/features/node:1": {
"nodeGypDependencies": true,
"version": "19.7.0"
}
},

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [ 8080 ],
"appPort": [ 8080 ],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "go version",

// Configure tool-specific properties.
// "customizations": {},

"mounts": [
{
"type": "bind",
"source": "/usr/local/determined/etc",
"target": "/etc/determined"
},
{
"type": "volume",
"source": "dev-home",
"target": "/home"
},
{
"type": "volume",
"source": "dev-go",
"target": "/go"
},
{
"type": "volume",
"source": "dev-usr",
"target": "/usr"
},
{
"type": "volume",
"source": "dev-var",
"target": "/var"
}
],

"runArgs": [
"--network=host"
],

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root",
"privileged": true,

"postStartCommand": ".devcontainer/start.sh"
}
9 changes: 9 additions & 0 deletions .devcontainer/server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -xeuo pipefail

VERSION=$(cat VERSION)
GO_LDFLAGS="-X github.com/determined-ai/determined/master/version.Version=${VERSION}"

nodemon --watch './**/*' -e go --signal SIGTERM --exec \
go run -ldflags "${GO_LDFLAGS}" \
./master/cmd/determined-master -- --log-level debug 2>&1
27 changes: 27 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -xeuo pipefail

if [ -z "$(command -v helm)" ]; then
curl -L https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
fi
if [ -z "$(command -v protoc)" ]; then
curl --retry-connrefused --retry 10 -o /tmp/protoc.zip -L https://github.com/protocolbuffers/protobuf/releases/download/v3.20.3/protoc-3.20.3-linux-x86_64.zip
sudo unzip -o /tmp/protoc.zip -d /usr/local
fi
if [ -z "$(command -v nodemon)" ]; then
npm i -g nodemon
fi

make get-deps

make -C proto build
make -C harness build
make -C webui build
make -C docs build
make -C agent build

make -C tools prep-root
sudo mkdir -p /usr/share/determined
sudo ln -sfT ${PWD}/tools/build /usr/share/determined/master

sudo chmod a+w /var/cache
13 changes: 13 additions & 0 deletions .devcontainer/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -xeuo pipefail

STAMP=${HOME}/.determined-setup.stamp
if [ ! -f ${STAMP} ]; then
.devcontainer/setup.sh
touch ${STAMP}
fi

LOG=${HOME}/determined-server.log
touch ${LOG}
nohup .devcontainer/server.sh >>${LOG} &
tail -f ${LOG}

0 comments on commit 22eeec6

Please sign in to comment.