update vscode template

This commit is contained in:
rushtehrani
2021-01-29 15:37:59 -08:00
parent dcab30f839
commit bd052005f1
3 changed files with 99 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
package migration
import (
"database/sql"
"github.com/pressly/goose"
"path/filepath"
)
func initialize20210129152427() {
if _, ok := initializedMigrations[20210129152427]; !ok {
goose.AddMigration(Up20210129152427, Down20210129152427)
initializedMigrations[20210129152427] = true
}
}
// Up20210129152427 migration will add lifecycle hooks to VSCode template.
// These hooks will attempt to export the conda, pip, and vscode packages that are installed,
// to a text file.
// On workspace resume / start, the code then tries to install these packages.
func Up20210129152427(tx *sql.Tx) error {
// This code is executed when the migration is applied.
return updateWorkspaceTemplateManifest(
filepath.Join("workspaces", "vscode", "20210129152427.yaml"),
vscodeWorkspaceTemplateName)
}
// Down20210129152427 removes the lifecycle hooks from VSCode workspace template.
func Down20210129152427(tx *sql.Tx) error {
// This code is executed when the migration is rolled back.
return updateWorkspaceTemplateManifest(
filepath.Join("workspaces", "vscode", "20201028145443.yaml"),
vscodeWorkspaceTemplateName)
}

View File

@@ -89,6 +89,7 @@ func Initialize() {
initialize20210118175809()
initialize20210129134326()
initialize20210129142057()
initialize20210129152427()
if err := client.DB.Close(); err != nil {
log.Printf("[error] closing db %v", err)

View File

@@ -0,0 +1,65 @@
containers:
- name: vscode
image: onepanel/vscode:1.0.0
command: ["/bin/bash", "-c", "pip install onepanel-sdk && /usr/bin/entrypoint.sh --bind-addr 0.0.0.0:8080 --auth none ."]
ports:
- containerPort: 8080
name: vscode
volumeMounts:
- name: data
mountPath: /data
lifecycle:
postStart:
exec:
command:
- /bin/sh
- -c
- >
condayml="/data/.environment.yml";
vscodetxt="/data/.vscode-extensions.txt";
if [ -f "$condayml" ]; then conda env update -f $condayml; fi;
if [ -f "$vscodetxt" ]; then cat $vscodetxt | xargs -n 1 code-server --install-extension; fi;
preStop:
exec:
command:
- /bin/sh
- -c
- >
conda env export > /data/.environment.yml -n base;
code-server --list-extensions | tail -n +2 > /data/.vscode-extensions.txt;
- name: sys-filesyncer
image: onepanel/filesyncer:0.18.0
imagePullPolicy: Always
args:
- server
- -server-prefix=/sys/filesyncer
volumeMounts:
- name: data
mountPath: /data
- name: sys-namespace-config
mountPath: /etc/onepanel
readOnly: true
ports:
- name: vscode
port: 8080
protocol: TCP
targetPort: 8080
- name: fs
port: 8888
protocol: TCP
targetPort: 8888
routes:
- match:
- uri:
prefix: /sys/filesyncer
route:
- destination:
port:
number: 8888
- match:
- uri:
prefix: /
route:
- destination:
port:
number: 8080