Skip to content

Commit

Permalink
Initial commit of vscode container
Browse files Browse the repository at this point in the history
  • Loading branch information
eveld committed Dec 17, 2024
1 parent f3e1102 commit b2b8a42
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build docker
on:
workflow_call:
inputs:
context:
type: string
required: true
workload_identity_provider:
type: string
required: false
default: "projects/1095590792109/locations/global/workloadIdentityPools/github-actions/providers/github"
service_account:
type: string
required: false
default: "[email protected]"


# Required by gcloud auth
permissions:
contents: read
id-token: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v2
with:
token_format: 'access_token'
workload_identity_provider: ${{ inputs.workload_identity_provider }}
service_account: ${{ inputs.service_account }}

- name: Login to GCR
uses: docker/login-action@v3
with:
registry: gcr.io
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: gcr.io/instruqt/vscode
tags: |
type=semver,pattern={{version}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: vscode
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outpu
13 changes: 13 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Build and Release
on:
push:
tags:
- "v*.*.*"

jobs:
vscode:
build-docker:
uses: instruqt/lab-agent/.github/workflows/docker.yml@main
with:
context: vscode
secrets: inherit
23 changes: 23 additions & 0 deletions vscode/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM codercom/code-server:4.95.3-debian

RUN sudo apt update && sudo apt install -y \
curl wget zip git jq build-essential software-properties-common fonts-jetbrains-mono

ARG EXTENSIONS=""
ENV EXTENSIONS=${EXTENSIONS}

COPY files/install_dependencies.sh /install_dependencies.sh
RUN sudo chmod +x /install_dependencies.sh ; /install_dependencies.sh

COPY files/settings.json /home/coder/.local/share/code-server/Machine/settings.json
COPY files/config.yaml /home/coder/.config/code-server/config.yaml

ENV DEFAULT_FOLDER="/home/coder"

COPY files/entrypoint.sh /entrypoint.sh
RUN sudo chmod +x /entrypoint.sh

RUN sudo chown -R coder:coder /home/coder/.local/share/code-server
RUN mkdir -p /home/coder/.local/share/code-server/coder-logs

ENTRYPOINT ["/entrypoint.sh"]
9 changes: 9 additions & 0 deletions vscode/files/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
bind-addr: 127.0.0.1:8080
auth: none
cert: false
disable-telemetry: true
disable-update-check: true
disable-workspace-trust: true
disable-getting-started-override: true
ignore-last-opened: true
app-name: instruqt
2 changes: 2 additions & 0 deletions vscode/files/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
code-server --bind-addr="0.0.0.0:8000" --disable-workspace-trust ${DEFAULT_FOLDER}
20 changes: 20 additions & 0 deletions vscode/files/install_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash -ex

for extension in ${EXTENSIONS//,/$IFS}; do
OUTPUT=$(code-server --install-extension $extension)
if [[ ! ${OUTPUT} =~ 'successfully installed' ]]; then
echo "fallback"
AUTHOR=$(echo $extension | cut -d '.' -f 1)
PACKAGE=$(echo $extension | cut -d '.' -f 2 | cut -d '@' -f 1)
VERSION=$(echo $extension | cut -d '@' -f 2)
curl -L --retry 5 -o extension.gz https://marketplace.visualstudio.com/_apis/public/gallery/publishers/${AUTHOR}/vsextensions/${PACKAGE}/${VERSION}/vspackage
gunzip extension.gz
mv extension extension.vsix
RETRY=$(code-server --install-extension extension.vsix)
rm extension.vsix
if [[ ! ${RETRY} =~ 'successfully installed' ]]; then
echo "could not install package"
exit 1
fi
fi
done
21 changes: 21 additions & 0 deletions vscode/files/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"workbench.startupEditor": "none",
"workbench.colorTheme": "Visual Studio Dark",
"explorer.confirmDragAndDrop": false,
"editor.minimap.enabled": false,
"vsonline.accountProvider": "Microsoft",
"codespaces.accountProvider": "Microsoft",
"editor.scrollBeyondLastLine": false,
"liveshare.authenticationProvider": "GitHub",
"editor.tabSize": 4,
"terminal.integrated.fontFamily": "JetBrains Mono",
"workbench.editorAssociations": {
},
"terminal.explorerKind": "external",
"security.workspace.trust.untrustedFiles": "open",
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"terminal.integrated.tabs.enabled": false,
"git.ignoreRebaseWarning": true,
"editor.accessibilitySupport": "off"
}

0 comments on commit b2b8a42

Please sign in to comment.