Skip to content

Commit

Permalink
ci(docker-build): add code-server layer
Browse files Browse the repository at this point in the history
  • Loading branch information
vpayno committed Jan 3, 2024
1 parent 1ed0d65 commit 88b5e3e
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/citools/includes/wrapper-library
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ set -o pipefail

declare -xr LLVM_VER=16

if [[ -f /etc/os-release ]]; then
. /etc/os-release
fi

declare DISTRO_ID="${ID}" # debian
if [[ -z ${ID} ]]; then
# shellcheck disable=SC2034
DISTRO_ID="distro_id_not_set"
fi

if [[ -z ${VERSION_CODENAME} ]]; then
VERSION_CODENAME="distro_release_not_set" # bookworm
fi

# helper functions

md_code_tag() {
Expand Down
87 changes: 87 additions & 0 deletions .github/docker/layer-25.00-tools-vscode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash
#
# .github/docker/layer-25.00-tools-vscode.sh
#

set -o pipefail

# this path from for the container
# shellcheck disable=SC1091
. /.github/docker/include

# shellcheck disable=SC1091
source /.github/citools/includes/wrapper-library || exit

main() {
declare -i retval=0

layer_begin "${0}" "$@"

declare -a PACKAGES
PACKAGES=(
apt-transport-https
ca-certificates
gpg
libc6
libstdc++6
tar
wget
)

echo Running: apt install -y "${PACKAGES[@]}"
time apt install -y "${PACKAGES[@]}" || track_errors
printf "\n"

echo Running: wget -qO- https://packages.microsoft.com/keys/microsoft.asc \| gpg --dearmor \| tee /tmp/packages.microsoft.gpg
time wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | tee /tmp/packages.microsoft.gpg || track_errors
printf "\n"

echo Running: install -D -o root -g root -m 644 /tmp/packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
time install -D -o root -g root -m 644 /tmp/packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg || track_errors
printf "\n"

# get list of available repos from: https://packages.microsoft.com/repos/
echo Creating /etc/apt/sources.list.d/vscode.list
local -a repos=("code")
local repo
for repo in "${repos[@]}"; do
printf "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/%s stable main\n" "${repo}"
done | tee /etc/apt/sources.list.d/vscode.list || track_errors
printf "\n"

echo Running: apt update
time apt update || track_errors
printf "\n"

# echo Running: apt install -y code
# time apt install -y code || track_errors
# printf "\n"

local latest_cs_ver
local cpu_arch
local cs_deb
local cs_url

latest_cs_ver="$(curl -sS https://api.github.com/repos/coder/code-server/releases/latest | jq -r .name)"

cpu_arch="$(dpkg --print-architecture)"

cs_deb="$(curl -sS https://api.github.com/repos/coder/code-server/releases/latest | jq -r '.assets[].name' | grep "${cpu_arch}.deb")"

cs_url="https://github.com/coder/code-server/releases/download/${latest_cs_ver}/${cs_deb}"

echo Running: wget --no-verbose --continue "${cs_url}" --output-document="/tmp/${cs_deb}"
time wget --no-verbose --continue "${cs_url}" --output-document="/tmp/${cs_deb}" || track_errors
printf "\n"

echo Running: apt install -y "/tmp/${cs_deb}"
time apt install -y "/tmp/${cs_deb}" || track_errors
printf "\n"

layer_end "${0}" "$@"

echo Running: return "${retval}"
return "${retval}"
}

time main "${@}" |& tee "${HOME}"/layer-25.00-tools-vscode.log
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ RUN bash .github/docker/layer-16.00-exercism-go.sh ci-generic-debian && : 202401

RUN bash .github/docker/layer-17.00-exercism-ruby.sh ci-generic-debian && : 20231103-000

RUN bash .github/docker/layer-25.00-tools-vscode.sh ci-generic-debian && : 20240102-000

RUN bash .github/docker/layer-99.00-summary.sh ci-generic-debian && : 20231103-000

# Copies your code file from your action repository to the filesystem path `/` of the container
Expand Down

0 comments on commit 88b5e3e

Please sign in to comment.