Skip to content
This repository has been archived by the owner on Oct 16, 2023. It is now read-only.

Commit

Permalink
Adding initial code server (#31)
Browse files Browse the repository at this point in the history
Signed-off-by: Bill Maxwell <[email protected]>
  • Loading branch information
cloudnautique authored Mar 6, 2023
1 parent 3687440 commit 0c80591
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 0 deletions.
97 changes: 97 additions & 0 deletions code-server/Acornfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
args: {
password: ""

// Check out a git repo on startup.
gitRepo: ""
}
containers: "code-server": {
build: context: "."
ports: publish: "8443/http"
env: {
PASSWORD: "secret://code-server-password/token"
}
dirs: {
"/config": "volume://src-volume"
}
sidecars: {
"install-extensions": {
init: true
build: context: "."
dirs: {
"/config": "volume://src-volume"
}
files: {
"/acorn/bootstrap.sh": "\(localData.extensions.bootstrap)"
}
command: [
"sh",
"-c",
"/acorn/bootstrap.sh",
]
}
if args.gitRepo != "" {
"git-checkout": {
init: true
image: "alpine/git:v2.36.3"
dirs: {
"/config": "volume://src-volume"
}
files: {
"/acorn/init.sh": "\(localData.git.initScript)"
}
entrypoint: "/bin/sh /acorn/init.sh"
}
}
}
}

secrets: "code-server-password": {
type: "token"
data: {
token: args.password
}
}

volumes: "src-volume": {}

localData: {
code: {
uid: 911
gid: 911
}
git: {
sshCommand: "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
user: "root"
initScript: """
#!/bin/sh
set -x
set -e
ssh_dir="/\(localData.git.user)/.ssh/"
export GIT_SSH_COMMAND="\(localData.git.sshCommand)"

/bin/mkdir -p ${ssh_dir}
/bin/chmod 700 ${ssh_dir}
# sometimes the keys arent mounted
sleep 3
files=$(ls /acorn/ssh|wc -l)
if [ "${files}" -gt "0" ]; then
cp /acorn/ssh/* ${ssh_dir}
chmod 600 ${ssh_dir}/*
fi

if [ -d "/config/workspace/src_repo" ]; then
exit 0
fi
git clone \(args.gitRepo) /config/workspace/src_repo && chown -R \(localData.code.uid):\(localData.code.gid) /config/workspace/src_repo
"""
}
extensions: {
bootstrap: """
#!/bin/sh
set -x
set -e
curl -L https://github.com/acorn-io/vscode-acorn/releases/download/v0.2.1/acorn-0.2.1.vsix > /tmp/acorn.vsix
install-extension /tmp/acorn.vsix
"""
}
}
3 changes: 3 additions & 0 deletions code-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM linuxserver/code-server

RUN curl -sfL https://get.acorn.io | sh
32 changes: 32 additions & 0 deletions code-server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Code Server

---
This is an Acorn with code-server, Acorn CLI, and Acorn VSCode extension preinstalled.

## Quickstart

To quickly deploy a code-server environment run the Acorn:

```bash
acorn run ghcr.io/acorn-io/library/code-server
```

A password will be automatically generated for you, to obtain it, run:

```bash
acorn secrets
# ...
#code-server-password-XXXXX
```

Look for the secret named code-server-password-[5 letter string] then run:

```bash
acorn secret reveal code-server-password-[5 letter string]
```

Copy the Value and open the URL to the running instance. Paste the password when prompted and start using code-server environment.

## Advanced Usage

You can check out a public source repository over http(s) on launch by passing in `--git-repo`.

0 comments on commit 0c80591

Please sign in to comment.